POV-Ray : Newsgroups : povray.general : Why does POV always evaluate both expressions with a '&'? : Re: Why does POV always evaluate both expressions with a '&'? Server Time
7 Aug 2024 11:22:41 EDT (-0400)
  Re: Why does POV always evaluate both expressions with a '&'?  
From: Thorsten Froehlich
Date: 27 Sep 2001 13:03:06
Message: <3bb35bca@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.