C# Empty Statement
while (GetWhitespace(textStream)) ;
while (GetWhitespace(textStream)) ;
The -1 is because integers start at 0, but our counting starts at 1. So, 2^32-1 is the maximum value for a 32-bit unsigned integer (32 binary digits). 2^32 is the number of possible values. To simplify why, look at decimal. 10^2-1 is the maximum value of a 2-digit decimal number (99). Because our intuitive … Read more
Warning: this is a really long explanation, but hopefully it really explains not only what SFINAE does, but gives some idea of when and why you might use it. Okay, to explain this we probably need to back up and explain templates a bit. As we all know, Python uses what’s commonly referred to as … Read more
I think the succinct summary of why null is undesirable is that meaningless states should not be representable. Suppose I’m modeling a door. It can be in one of three states: open, shut but unlocked, and shut and locked. Now I could model it along the lines of class Door private bool isShut private bool … Read more
There isn’t really a standard name for this case convention, and there is disagreement over what it should be called. That said, as of 2019, there is a strong case to be made that kebab-case is winning: https://trends.google.com/trends/explore?date=all&q=kebab-case,spinal-case,lisp-case,dash-case,caterpillar-case spinal-case is a distant second, and no other terms have any traction at all. Additionally, kebab-case has … Read more
It turns out that SQL can be Turing Complete even without a true ‘scripting’ extension such as PL/SQL or PSM (which are designed to be true programming languages, so that’s kinda cheating). In this set of slides Andrew Gierth proves that with CTE and Windowing SQL is Turing Complete, by constructing a cyclic tag system, … Read more
The short answer is don’t. Syntax conventions make your code readable and understandable for others. Scala’s convention is that variables start with lower-case and constants and classes start with upper-case. By violating this, not only you get problems like pattern-matching issues, your code becomes less readable. (Believe me, if you ever have to read code … Read more
Watch this lecture. The idea is that your program is a combination of a datatype and operations over it. The problem asks for an implementation that allows to add new cases of the type and new operations without the need for recompilation of the old modules and keeping static type safety(no casts or runtime type … Read more
One useful construct is for example: char *pBuffer; if (pBuffer = malloc(100)) { // Continue to work here } As mentioned before, and downvoted several times now, I might add this is not specially good style, but I have seen it often enough to say it’s useful. I’ve also seen this with new, but it … Read more
Instead of calling /usr/bin/gcc, use /usr/bin/c99. This is the Single-Unix-approved way of invoking a C99 compiler. On an Ubuntu system, this points to a script which invokes gcc after having added the -std=c99 flag, which is precisely what you want.