On Fri, Nov 15, 2002 at 04:28:26PM -0600, Ben Combee wrote:
>>> [...] RecordSize+=(len=StrLen(Data.Field2))+((len>0)?1:0);
> 
> The only C/C++ operators that have an implied order are the shortcut 
> evaluation operators || and &&.

And also ?: and , and several other (non-operator) contexts.
The buzzword to look for in the standards, FAQs, and newsgroups is
"sequence point".

Me, I didn't think the bad programming practice in the original code was
the use of the ?: operator, but rather the way the code is all scrunched
together instead of spelling out what it's really doing.  Compare

        if ((len = StrLen (Data.Field2)) > 0)  RecordSize += len + 1;

which doesn't contain a sequence point violation.  That's not a
coincidence :-).  (Yes, I realise some would prefer to see it written
out even more verbosely.)

    John

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to