Re: pause/cont

2005-09-22 Thread TSa

HaloO,

Juerd wrote:

Both recently discussed situations with blocks can be solved by
introducing a way to leave the current block and resume it elsewhere.


With first class code types, _ and label beeing bound lexically
to the current instance of the sub class, the set of current control
flow procedures (next, leave, goto, ...) are sufficient.



Skipping the check after it matched the first time:

my macro loopbody { ... }

for (...) {

pause, next if condition;
loopbody;
}
cont {
loopbody;
}


Why not simply:

   for (...)
   {
  if condition
  {
 # or OUTER::_ ?
 _ = loopbody; # or (re)binding with := ?
 next if first_true_skips_loopbody_once;
  }

  loopbody:
  ...
   }

Only drawback is that assignment to _ plays in the
same league of bad programming practices as goto.
OTOH, I expect the optimizer to pull exactly the above
stunt given enough type information about the condition.
And I hope we all agree, that goto behind the scenes is
not a bad thing :)
--
$TSa.greeting := HaloO; # mind the echo!


Re: pause/cont

2005-09-22 Thread Juerd
TSa skribis 2005-09-22 14:55 (+0200):
 Why not simply:
   loopbody:

Because I don't like non-block labels. It reminds me too much of
bad-goto.

This, and I fear this would have bad performance. That's based on
nothing, though.

 And I hope we all agree, that goto behind the scenes is
 not a bad thing :)

I still consider sub calls, loops, conditions, etc, to be controlled
forms of goto. They're good-goto.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html