Reputation
5,090
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
7 25
Newest
 Nice Answer
Impact
~146k people reached

Jun
26
awarded  Nice Answer
Jun
24
comment How safe is it to compile a piece of source code from a random stranger?
C++ indeed limits the instantiation depth of templates to some implementation-dependent value. This used to be a few dozen; modern implementations have raised the limit to several hundred. Still, it's completely trivial to double the number of templates instantiations per level, so 100 levels would require the compiler to instantiate 2^100 templates. That's till just a DoS attack.
Jun
23
comment Would you create a specialized type just to wrap a primitive?
F# got the idea from C++. IIRC, Fermi Labs developed the SI units lib around 2002 or so. No performance impact of course, C++ has no abstraction penalty for such simple wrappers. And it correcly resolves that Length L; L==2; is invalid. 2 is a dimensionless number (meters^0), length is not (meters^1). That's a straightforward type error. Instead, use L==2_m (user-defined literals)
Jun
23
answered Avoid numeric errors in Naive Bayes method
Jun
14
comment Why do programs use call stacks, if nested function calls can be inlined?
@user2357112: Not all stack are call stacks. In particular, a call stack contains stack frames for every non-inlined funtion that's been called but hasn't returned yet.
Jun
13
comment Why do programs use call stacks, if nested function calls can be inlined?
@mastov: Why would recursion prevent inlining? Modern compilers actually do inline recursive calls.
Jun
13
comment Why do programs use call stacks, if nested function calls can be inlined?
@R.. : LTO is LINK time Optimization, not LOAD Time Optimization.
Jun
12
comment Is my mentor's concern for code quality excessive?
Programming is actually quite tolerant in that respect. Creativity in chess is all at the strategic level; inventing new moves for your chess pieces is frowned upon ;)
Jun
12
comment Why do programs use call stacks, if nested function calls can be inlined?
@Blrfl: Modern compilers actually don't need definitions in the header anymore; they can inline across Translation Units. This does require a decent linker, though. Definitions in header files are a workaround for dumb linkers.
Jun
9
answered Are “plus” and “minus” appropriate method names?
Jun
9
comment What is the “type” of data that pointers hold in the C language?
You're also permitted to take the difference between two pointers p1-p2. The result is a signed integral value. In particular, &(array[i])-&(array[j]) == i-j
Jun
9
comment What is the “type” of data that pointers hold in the C language?
Indeed. The best known counterexample is the Intel 8086, where pointers are two integers.
May
28
comment How do I model this Shipping Routes scenario?
@SolilquyOfChaos: Please note, that's a Graph class intended for Dependency Graphs. Dependency Graphs have an important property : they're never cyclic. And your graph definitely is cyclic.
May
28
comment How do I model this Shipping Routes scenario?
@SolilquyOfChaos: The graph is small enough that you don't absolutely need it. At that point you're almost answering the questions by hand. But the intent of this question really is to make the small graph and solve the 5 problems on that graph.
May
28
comment How do I model this Shipping Routes scenario?
Are you familiar with Graph Theory?
May
21
comment When NOT to use virtual destructors?
@Yakk: Obviously you can't have a recursive function in such a system. More importantly, the function type now depends on the implementation and not just the signature. How would you define pointers to functions?
May
21
comment When NOT to use virtual destructors?
It's also nonsense that dynamic memory cannot be used in hard real-time systems. It's fairly trivial to prove that a preconfigured heap with fixed allocation sizes and an allocation bitmap will either allocate memory or return an out-of-memory condition in the time it takes to scan that bitmap.
May
4
comment Should we define types for everything?
"strings often become the 'universal' data type" - that's the origin of the tongue-in-cheek "stringly typed languages" moniker.
May
4
comment Should we define types for everything?
I'm not sure where the idea comes from that C++ has an overhead on types. With C++11, none of the compiler makers saw a problem in giving each lambda its own unique type. But TBH you can't really expect to find a lot of insight in a comment about the "C/C++ type system" as if the two share a type system.
Apr
29
comment Should I validate a method call's return value even if I know that the method can't return bad input?
Why are you focusing on just one problem (Null)? It's probably equally problematic if the name is "" (not null but the empty string) or "N/A". Either you can trust the result, or you have to be appropriately paranoid.