> : I believe Perl 6 hasn't changed its policy on
> : labels, so you should be
> : able to write that in Perl 6.  But your behavior
> : might be undefined.
> : It's weird to jump into the middle of a loop.
> : We may only allow you to
> : jump outwards from your dynamic scope.
> 
> Perl 5's policy is to prohibit goto into
> anything that has to execute code to set up
> execution of the block, so you can't jump into a
> foreach loop, but you can jump into more basic
> sorts of loops.

In the last compiler I wrote, every node in the syntax
tree had a set of blocks of code that needed to be
emitted for various events. Just as finally (using
Java terminology, here, haven't kept up enough to know
Perl6's names for these things) blocks get executed
when falling out of a block, there were blocks for
entering, blocks for entering at the beginning
('falling in', so to speak), blocks for exiting,
blocks for exiting by 'falling out', blocks for
exiting via return, and blocks for exiting via
exception. When the compiler generated code for a
goto, it would simply emit exit code for all the
blocks it had to leave, and enter code for all the
blocks it went into. Setting up and tearing down pads
were part of the unconditional enter and exit blocks,
and these blocks could also be specified by the
language programmer like so:

  do {
    stuff
  } enter {
    set-up-code
  } exit {
    tear-down-code
  } rescue {
    exception-handling-code
  }

It had a nice symmetry to it.


                
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

Reply via email to