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

  • 0 posts edited
  • 1 helpful flag
  • 3,107 votes cast
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
Dec
12
comment Why are there so many spaces and line breaks in Unicode?
xkcd.com/927
Aug
31
answered “Ever change the value of 4?” - how did this come into Hayes-Thomas quiz?
Aug
16
comment Why are packed structures not part of the C language?
It would be possible to make unaligned access work on systems that don't support it in hardware by implementing such structs as an array of bytes and performing the necessary bit-shifting and &/| operations to read/write the values of each field.