POV-Ray : Newsgroups : povray.advanced-users : Negative subscript in while loop : rt_circuiting_is_veeeery_common_in_C=2e? Server Time
24 Feb 2024 17:49:14 EST (-0500)
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?
> 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?
> 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-2023 Persistence of Vision Raytracer Pty. Ltd.