It's legal because, unlike the example given in that FAQ entry you referenced, there's an implicit ordering in the expression that even the most aggressive compiler optimizer couldn't change. In order for the value of parse_char_class() to be returned, its arguments must obviously be evaluated first and that means that ++nd will always occur before the assignment operator.
Stylistically, of course, it's ugly as hell and would be dinged by any CS professor grading this as homework. Is nd a local variable? If so, why didn't the author simply pass "nd + 1" as the argument since the extra assignment from the unary operator is essentially wasted cycles? Or is nd a global variable also referenced from within parse_char_class(), thus requiring the use of the ++ operator and if so, then why didn't parse_char_class() simply side-effect the global rather than forcing a re-assignment from within the parent function? Indeed, why is nd a global at all? These and other questions are left as an exercise for the reader. :-)
- Jordan
On Wednesday, November 6, 2002, at 08:46 AM, Marc Olzheim wrote:
.. if ((nd = parse_char_class(++nd)) == NULL) { .. Hmmm... is this legal ?http://www.eskimo.com/~scs/C-faq/q3.1.html seems to tell otherwise... Zlo To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
-- Jordan K. Hubbard Engineering Manager, BSD technology group Apple Computer To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message