On Sat, 2005-05-14 at 18:04 -0700, Tom Jennings wrote:
>>
>> int i = 0; >> printf("%d %d %d\n",i++,i++,i++);
>> > IIRC it should output:
>>>>>>>>> AD NAUSEUM
Hey, WTF, over?! I thought you guys were all programmers?
The answer is: UNDEFINED. What it will print is UNDEFINED. Good
old K & R warns you of SIDE EFFECTS, most specifically
stupid-human assumptions about the order of evaluation.
No, it will not print "UNDEFINED" it will print something very well
defined.
Just not defined by the ANSI or ISO folks. It's defined by your friendly
neighborhood compiler writer.
In any event it may be stupid (and usually is) to create implementation
dependencies like this that a) are non-portable and b) are really hard
for joe-code-maintainer to understand without a well-crafted google
search.
Remember though that there are lots of cases where portability does not
matter. And if it's for your personal use joe-coder won't matter
either.
The only kind of software that matters is software that is compiled and
runs on a computer. One can only presume that it is (a) Real compiler(s)
and (a) Real computer(s) involved here, so all language implementation
and platform specific issues will be settled by reality.
The usual logic is to save yourself work later if it's easy to do
something different now. But you must always balance that against "You
Ain't Gonna Need It." One way to think of it is to maximize laziness
while meeting the hard requirements of functionality and schedule. They
don't pay you the big bucks to hit the would-be-nices, or to make a 6
level masterpiece of a class hierarchy, and certainly not to write an
entry for the obfuscated C contest, but rather to get it done as
required, on-time.
-- John.