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.
left-to-right short-circuit conditional evaluation?
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
and something exceedingly vile for the
|| case.
Code: Select all
if (a) if (b) { ...when both are true...}
|| case.