Reputation
2,905
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
1 16 23
Newest
 Yearling
Impact
~264k people reached

  • 0 posts edited
  • 1 helpful flag
  • 3,237 votes cast
Mar
22
comment Why do so few languages with a variable-type 'operator' exist?
Note that Python has a standard operator module that would let you write action = operator.add, and have it work for any type that defines + (not just int).
Feb
26
comment Why did BASIC use line numbers?
Some BASICs (e.g., Atari's) even allowed arbitrary numeric expressions to be used in GOTO statements. So, with a proper line numbering convention, you could write GOTO 1000+N*100 to emulate a switch statement.
Feb
26
comment Using output of GNU GPL software in commercial purposes
If you run GNU grep on the source code for a program, would you expect that program to become GPLed?
Jan
27
answered Can “return this” pattern be optimized to no cost performance?
Jan
21
comment Why does integer division result in an integer?
@MasonWheeler: At least C has the advantage of static typing, so you can tell what / is doing based on the type of its operands. In Python 2.x, you could write a function def mean(x, y): return (x+y)/2 and have mean(3.0, 4.0) == 3.5 but mean(3, 4) == 3. I got bitten by this a lot when I first started coding in Python.
Jan
7
awarded  Yearling
Dec
18
comment What is the conceptual difference between finally and a destructor?
A practical example I've encountered in JavaScript are functions that temporarily change the mouse pointer to an hourglass during some lengthy operation (which might throw an exception), and then change it back to normal in the finally clause. The C++ worldview would introduce a class that manages this “resource” of an assignment to a pseudo-global variable. What conceptual sense does that make? But destructors are C++'s hammer for required end-of-block code execution.
Oct
29
comment How are comments usually parsed?
In pre-Standard C, some implementations treated ident/* comment */ifier as a single token.
Sep
30
comment Type checking as opposed to multiple functions?
Why not name them negate and reverse instead of overloading the word flip for two completely different operations?
Sep
23
comment Ternary operator considered harmful?
code.isShort && code.isReadable && !code.hasComplexCondition ? UseTernaryOperator() : UseIfElseStatement();
Aug
27
comment Why are C string literals read-only?
Your "moregex" example wouldn't work because of null termination.
Aug
20
comment Why does Python's math.ceil return a float?
@CodesInChaos: Python 3.4's math.ceil throws an OverflowError for infinity, or ValueError for NaN.
Aug
19
answered Checking array size in C/C++ to avoid segmentation faults
Jul
28
awarded  Nice Answer
Jun
26
answered Has variable width types been replaced by fixed types in modern C?
Jun
25
comment Has variable width types been replaced by fixed types in modern C?
Related: stackoverflow.com/questions/24444356/…
Jun
19
comment What stops C from being compiled/interpreted/JIT'ed?
It's possible to emulate 32-bit arithmetic on a 36-bit machine ANDing the result of every operation with 0xFFFFFFFF to truncate it to 32-bits. So, these machines could implement Java, it would just be slower than if Java allowed nonet-based types.
May
18
awarded  Nice Answer
Jan
21
awarded  Good Answer
Jan
7
awarded  Yearling