POV-Ray : Newsgroups : povray.advanced-users : Negative subscript in while loop : rt_circuiting_is_veeeery_common_in_C=2e? Server Time
4 Feb 2023 23:47:41 EST (-0500)
  rt_circuiting_is_veeeery_common_in_C=2e?  
From: Lars Rohwedder
Date: 17 Jan 2023 01:40:27
Message: <63c642db@news.povray.org>
> You may want to have a look at these questions, answers and comments::
> 
> What is "short-circuiting" in C like languages?
>
https://softwareengineering.stackexchange.com/questions/201896/what-is-short-circuiting-in-c-like-languages
> 
> What is short-circuit evaluation in C?
> https://stackoverflow.com/questions/45848858/what-is-short-circuit-evaluation-in-c
> 
> Is short-circuiting logical operators mandated? And evaluation order?
>
https://stackoverflow.com/questions/628526/is-short-circuiting-logical-operators-mandated-and-evaluation-order
> 
> 
> My opinion is that writing code that depends on short circuiting is
> bad practice (i.e. hard to understand and debug - and not so portable,
> as you have now experienced).

But in C those expressions are a quite common idiome, like

#define IsNullOrEmpty(s)  ((s)==NULL || (s)[0]=='\0')

or – even more common - in expressions like this:

if( s && s->value )
{
    …
}

and a lot of C code rely on the short circui rule in these expressions.

And – IMHO – these expressions are not hard to debug, because 's' can be 
evaluated easily e.g. in a debugger.

But of course, PovRay scene files are not C. :-)

Lars R.


Post a reply to this message

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