Pascal-like C via macros is a separate issue: http://thedailywtf.com/Articles/_0x23_include__0x22_pascal_0x2e_h_0x22_.aspx
For-loop-insanity
What do you mean? Everyone I know codes in Better C!Why would one redefine the language like that? Too much to type? It is almost like you need to learn a new language inside the language you already know, lol... Unless I completely missed a point.
It actually doesn't look that stupid when you put it like that.
I was thinking to add things like:
#define BEGIN {
#define END }
So it looks a bit more like Pascal too.
That's exactly what Bourne did when he wrote his original shell, because he was more familiar with ALGOL.
Pascal-like C via macros is a separate issue: http://thedailywtf.com/Articles/_0x23_include__0x22_pascal_0x2e_h_0x22_.aspx
Oh dear, that is Pascal... no, it is C... :D Absolutely hilarious these <what do we call them>? If I remember correctly, Pascal had assignment operator '<variable> := <value>;' ? (colon+equality)?
It actually doesn't look that stupid when you put it like that.
I was thinking to add things like:
#define BEGIN {
#define END }
So it looks a bit more like Pascal too.
That's exactly what Bourne did when he wrote his original shell, because he was more familiar with ALGOL.
Oh dear... I am not old enough for ALGOL. :D Bourne, I have heard of, actually. He made the predecessor to BASH (Bourne Again SHell).
I never thought I would learn and laugh so much for posting a silly for-sentence in a forum, lol. :D
Wait, is it me or did nobody point out that the compiler would have also complained about that second loop in the first post? (reason: condition is always true)
Wait, is it me or did nobody point out that the compiler would have also complained about that second loop in the first post? (reason: condition is always true)
Xcode did certainly not complain. Let me double check that.
Nope. No complaints. Xcode is happy... I even tried the static analyzer, and it just replied "Build Succeeded". "No Issues".
For GCC second one gets a warning if -Wtype-limits (which is enabled by -W aka -Wextra but not by -Wall) is enabled.
Clang possibly acts the same because it (kinda) tries to be compatible with GCC.
While we are in topic of loops, this is an example from one zlib game codebase I found online:
#define loop(v,m) for(int v = 0; v<int(m); v++) #define loopi(m) loop(i,m) #define loopj(m) loop(j,m) #define loopk(m) loop(k,m) #define loopl(m) loop(l,m) #define loopirev(v) for(int i = v-1; i>=0; i--)
Is that cube/sauerbraten? I have nightmares about portions of that codebase...