At 00:00 2002-11-16 +0100, you wrote:
Right... I was thinking binary operators -- <foo> ? <bar> : <baz> does have embedded sequence points.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.)
Much improved style in your reformulation, although I'd probably cringe a
little at the embedded assignment in the if, as my spidey-sense would go
off at seeing a single '=' in an if expression.--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
