POV-Ray : Newsgroups : povray.off-topic : Programming style question - specifically Python : Re: Programming style question - specifically Python Server Time
29 Jul 2024 20:22:06 EDT (-0400)
  Re: Programming style question - specifically Python  
From: Darren New
Date: 26 Aug 2011 19:26:29
Message: <4e582ba5$1@news.povray.org>
On 8/26/2011 7:48, Warp wrote:
>    You are not setting bool_b the value of bool_a.

And that's exactly my complaint. The value of bool_b is dependent on bool_a, 
but not really assigned from it. I'm sure you see what I mean.

> You are making a boolean
> 'and', and assigning the result of that to bool_b.

But when the first expression indicates the second can't be evaluated, 
there's no reason to assign the first expression to bool_b, semantically 
speaking. I.e., it looks to me like it's tying the two too closely.

> avoids the redundancy of the "else false" branch.

True. On the other hand, the value of bool_b is never used if bool_a is 
wrong, so unless your language insists it be assigned before use and doesn't 
initialize it for you, there's no real reason to assign to it at all if 
bool_a indicates the value is invalid.

> (It's a bit like that
> annoying "else break;" at the end of a loop, only in this case it's easily
> avoidable.)

I can see your point.

>    This is, btw, a common tactic used in unix shell scripts.

Yeah, but IME it's usually used *only* to short circut the evaluation, not 
to actually use the result. YMMV.

-- 
Darren New, San Diego CA, USA (PST)
   How come I never get only one kudo?


Post a reply to this message

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