left-to-right short-circuit conditional evaluation?

Anything that doesn't fit elsewhere.
Post Reply
jaambros
Posts: 29
Joined: Tue Oct 04, 2005 3:29 pm
Location: Ohio University

left-to-right short-circuit conditional evaluation?

Post by jaambros »

Is there a chance to use short-circuit (as in c and other prog langs) conditional evaluation in NEURON?

Take this example

oc> func a(){ print "a called" return 0}
oc> func b(){ print "b called" return 0}
oc> if( a() && b() ) print "none"
a called
b called

Once a() returned 0 there was no need to evaluate b().
Not only short-circuit evaluation is more efficient, but sometimes makes coding easier.
hines
Site Admin
Posts: 1692
Joined: Wed May 18, 2005 3:32 pm

Post by hines »

You are right. It does make coding easier and it should have been done that way from the beginning and would have been if I had spent a bit more effort on the extra stack machine logic required. Sadly, I think the legacy code problems prevent just changing the current behavior so one is forced to use the idiom

Code: Select all

if (a) if (b) { ...when both are true...}
and something exceedingly vile for the
|| case.
Post Reply