News for hackers. Stuff that matters.
Re:Printing 1 to 1000 without loop or conditionals by mfukar on Monday January 03, 2011 @05:23AM (#2062744)
If you want to get into language-lawyer mode, expressions are most certainly not conditional statements [in C]. But what's the use of arguing? "More gimmicky" answers don't count into solving a gimmicky problem? Who even keeps score?

edit: clarification, in true language-lawyer fashion.

Re:Printing 1 to 1000 without loop or conditionals by tptacek on Monday January 03, 2011 @01:45PM (#2064155)
The preprocessor hack does not compile to code that would decompile back to an if() statement. The i/1000 code does not compile to code that would decompile back to an if() statement. The ctor hack does not compile to code that would decompile back to a loop and an if statement. The i<1000 code, on the other hand, does compile down to code that decompiles back up to an if() statement; that's because it's just a compact way of writing an if() statement.

I'm not being a "language lawyer".

Re:Printing 1 to 1000 without loop or conditionals by mfukar on Monday January 03, 2011 @02:08PM (#2064262)
Well, neither C nor C++ are assembly, and vice versa. That's my usual response to this kind of "arguments", in every such question; boy do they come up a lot.

Regardless, I'll repeat it; maybe it'll stick this time:

  i < 0
is a conditional expression,

  if (i < 0) {}
is a conditional statement.

Also, while the above could be (mis)taken for C code;

  cmp eax, 0
  jl  foo
this one surely wouldn't.

And at this point I'll stop beating this particular horse.