|
|
In article <3bb34c82@news.povray.org> , Warp <war### [at] tagpovrayorg> wrote:
> How so? I don't see anything wrong there (of course if we imagine that we
> convert it to equivalent C code).
>
> The C standard *guarantees* that the expression at the right of && is not
> evaluated if the expression at the left is false. (The & operator in POV-Ray
> is equivalent to the && operator in C, and it should not be confused with
> the & operator in C, which does a completely different thing.)
Ups, I saw the & and didn't actually look at the whole expression or even
remembered that & in POV is && in C (I rarely 'use' POV). Of course for &&
and || left-to-right and only as much as is needed holds in C. Nevertheless,
only as an exception to the general rule (Section 5, Clause 4 & 5 ISO C++)
that the evaluation order is unspecified unless it is explicitly specified,
which it is for &&,||,?:,=. Personally I find it easier to always assume
the order and how much is unspecified (except for assignments of course) -
it makes the code much more readable even after years of not having looked
at it.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
|