For-loop-insanity

Started by
26 comments, last by FRex 9 years, 7 months ago

Pascal-like C via macros is a separate issue: http://thedailywtf.com/Articles/_0x23_include__0x22_pascal_0x2e_h_0x22_.aspx

Advertisement

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.

What do you mean? Everyone I know codes in Better C!

It actually doesn't look that stupid when you put it like that. biggrin.png

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.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

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. biggrin.png

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)

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

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...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Yes, that is vanilla Cube 2 : Sauerbraten. tongue.png

This topic is closed to new replies.

Advertisement