From: Mike McCarty (jmccarty_at_ssd.usa.alcatel.com)
Date: 2001-01-02 22:28:24
On Tue, 2 Jan 2001, Mirco Miranda wrote: > Spiro Trikaliotis ha scritto: > > > Hello, > > > > > Or, better, > > > > > > while ((c = *value) != 39 && c != 62) { > > > <stuff> > > > } > > > > Forgive me, but if my memory serves me right, C (at least pre-ANSI) does NOT > > define the order in which this will be evaluated, so the second part (c!=62) > > might be evaluated BEFORE the first part with the assignment, in that case, > > this will NOT evaluate to the expected condition. > > scuse me... probably I don't understand very well (I have some problem with english:-()), > but C work in corto-circuit when it evaluate a boolean expression. I don't speak Italian, but Spanish is my first language, and it sure looks like you are trying to say "short-circuit evaluation", which is correct. > In this case, it elaborate the first part (the part before the &&) and then (only if this is > TRUE) it check the second part otherwise (if the first part is FALSE) the result of boolean > expression is FALSE. Exactly. > In all things I prefer to use the "for" instead the "while" when I write a C program... I prefer to use syntax which reflects the way I think of the solution, rather than have pet preferred syntax. If I am incrementing a variable, I use ++, but if I am adding 1 to it, as opposed to incrementing it, I use += 1. A decent compiler generates the same code in either case. I like my programs to indicate by their style what they are trying to accomplish. The more hints I can give myself later, the better I like it. Mike ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:37 CET