Page 1 of 1

left-to-right short-circuit conditional evaluation?

Posted: Thu Mar 09, 2006 6:13 pm
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.

Posted: Sat Mar 11, 2006 8:47 am
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.