I love relational operators so much

A

Andrey Vul

C's handling of 'if' leads to a lot of room for obfuscation. All you
have to do is replace ';' with '|' for compound expressions and add
parentheses as neccessary.
if (x)
y;
else
z;
becomes
((x)&&(y))
||(z);

for compounds,
if (x)
y;z;a;b;
else
c;d;e;f;
becomes
((x) && ((y)|(z)|(a)|(b))
||((c)|(d)|(e)|(f));

C is so much fun to obfuscate. Gotta love ISO 9899.
The result is still more readable than perl, though.
 
A

Andrey Vul

C's handling of 'if' leads to a lot of room for obfuscation. All you
have to do is replace ';' with '|' for compound expressions and add
parentheses as neccessary.
if (x)
 y;
else
 z;
becomes
((x)&&(y))
||(z);

for compounds,
if (x)
 y;z;a;b;
else
 c;d;e;f;
becomes
((x) && ((y)|(z)|(a)|(b))
||((c)|(d)|(e)|(f));

Uh oh, | isn't gonna work on for- or while-loops.
 
E

Eric Sosman

Andrey said:
C's handling of 'if' leads to a lot of room for obfuscation. All you
have to do is replace ';' with '|' for compound expressions and add
parentheses as neccessary.
if (x)
y;
else
z;
becomes
((x)&&(y))
||(z);

I tried your suggestion, with `exit(0)' for `z', and
my compiler complained. Should I sue the vendor?
for compounds,
if (x)
y;z;a;b;
else
c;d;e;f;

... is a syntax error.
 
B

Beej Jorgensen

Eric Sosman said:
I tried your suggestion, with `exit(0)' for `z', and
my compiler complained. Should I sue the vendor?

vendor==MICROSOFT && printf("Sue Sue!\n"); // ;-)

-Beej
 
R

Richard Bos

Beej Jorgensen said:
vendor==MICROSOFT && printf("Sue Sue!\n"); // ;-)

You surprise me. I'd expect a M$-written implementation, if it started
emitting girls' names, to choose "Daisy, Daisy...".

Richard
 
D

dragan

Andrey said:
C's handling of 'if' leads to a lot of room for obfuscation. All you
have to do is replace ';' with '|' for compound expressions and add
parentheses as neccessary.

I see no love in that. "plonk" for false advertising.
 
P

Phil Carmody

Andrey Vul said:
C's handling of 'if' leads to a lot of room for obfuscation. All you
have to do is replace ';' with '|' for compound expressions and add
parentheses as neccessary.
for compounds,
if (x)
y;z;a;b;
else
c;d;e;f;
becomes
((x) && ((y)|(z)|(a)|(b))
||((c)|(d)|(e)|(f));

Codswallop. You clearly have avoided learning anything about
order of evaluation. Which, given that it's one of the most
commonly discussed things on c.l.c, is either terribly sloppy,
or deliberate. Neither being commendable.
C is so much fun to obfuscate. Gotta love ISO 9899.
The result is still more readable than perl, though.

Almost any language can be made practically un readable.
Some just make it trivial, or even natural.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top