Re: Short-circuit warning

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy, 

I want to show you the differences between short-circut evaluation
and non-short-circut evaluation.

Himm...  If you want to modify a variable while you compare it:

while (flag && ++c < 10) { .. } -- oops that is C.  
         We can't do that in Euphoria, anyway.

When you want to assign a variable so you don't need so many []'s:

if ( node[N_NEXT][4][6] == True && (color = node[N_NEXT][4][3]) == Red ) 
    { -- oops, that is C also.

When you want obtain information using pass by reference:

if ( foo == 5 or get_bar_value( &bar ) == false ) {
  .. -- careful not to use bar here.
  -- oops, that is also C.

You have to put a lot effort to construct a situation where
shortcircuting would keep a variable from being assigned or updated
properly.  The examples I gave are not even possible in EUPHORIA.
Unless you construct a function for updating a global variable
and bury it in the logic of an if-statement.  You see how
difficult it is for short-circuting to be a problem with program
logic?  

So, yes, I think think you have guessed correctly.  I am on Jeremy's
side on this issue.

Shawn Pringle

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu