Oh, that sentence confused me. You were expressing your disbelief at the program compiling. I thought you were asserting that it didn't compile (ie you wouldn't believe that it compiles).
In light of this new information, i've decided that you no longer need to suck it.
The question still remains, though. WTF is going on in that program.
Name:
Anonymous2007-04-10 14:27 ID:bft/vtSP
R-R-RETARDS !!
Name:
Anonymous2007-04-10 14:34 ID:L8x1jHHz
Idiots. It evaluates to TRUE
Name:
Anonymous2007-04-10 14:44 ID:YqaTtdxC
>>3
OP here i understood what's going on (finally)
strings is a unix command, and when i used it on the compiled program the string "example" didn't appear anywhere, so the compiler propably optimizes it or does something tricky i don't know.
Name:
Anonymous2007-04-10 15:17 ID:U1arqosk
>>16
That's what I was thinking. Because, according to my debugger, this program skips the "if" statement:
#include <iostream>
using namespace std;
>>18
He wanted to use C with magic, but also wanted a proper compiled language. He's kind of like a Java fence-sitter, only I can respect him just a little more.
Name:
Anonymous2007-04-13 18:58 ID:tUwmNyrc
lazy evaluation? in my C?
Name:
Anonymous2007-04-13 19:21 ID:zHrwNJpp
Tricky? It's standard issue optimization. A constant string evaluates to a pointer and a pointer is just an integer. The pointer is obviously not NULL which means it's an integer that is not equal to 0, in other words it evaluates to true and is no different from "if (1)". Also cout::operator<< is a function so the compiler cannot optimize it away since it may have side-effects (and it does, it writes to stdout). A statement that is a constant expression doesn't do anything so it can be thrown away.
Name:
Anonymous2007-04-14 1:49 ID:nchVaC2Y
"What happens?" and "Nothing" are stored as static strings; so in essence, you might as well say:
There is no effect here no matter what s1 or s2 are; even if s1 is null, the resultant statement of s2 does not constitute an action; and, if s1 is not null, then (void) 0 also has no effect. The statement is thus easily reduced to "Do Nothing" by any competent compiler.
Name:
Anonymous2007-04-14 3:30 ID:u0fPVPwq
>>22
Be careful, you are dealing with an idiot that doesn't understand strings and you put "Do Nothing" in quotes. He's probably trying to figure out how to output "Do Nothing" using his "What happens?" and "Nothing" strings in an if statement right now.
Name:
Anonymous2007-04-14 4:05 ID:2XPfo9dZ
retards.hs:3:0:
Couldn't match expected type `IO a' against inferred type `[Char]'
In the first argument of `GHC.TopHandler.runMainIO', namely `main'
When checking the type of the main function `main'
Name:
Anonymous2007-04-14 5:13 ID:KpofLTGp
>>22
LOL fuckind FAIL
You should REALLY listen to what EXPERT PROGRAMMERS have to say and stop acting like a fool.
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy