[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] awww, no fun :(



On Thu, Apr 12, 2001 at 08:05:50PM -0400, Bernie Cosell wrote:
> On 12 Apr 2001, at 13:34, Randal L. Schwartz wrote:
> 
> > No, it's deliberately worked that way since Perl version 1 (maybe 2)
> > when last/next/redo were created.
> > 
> > That's to be able to write loop controls like:
> > 
> > sub last_OUTER_if_int { last OUTER; }
> > 
> > { local $SIG{INT} = 'last_if_int';
> > 
> >   OUTER: while ($some_cond) {
> >     ...
> >     ...
> >     ...
> >     ...
> >   }
> > }
> 
> So how do you pass the label in as an argument --- you certainly don't 
> want to hardwire the label, right?   It is one thing to have non-local 
> actions like this, but it strikes me as a lot less than elegant if I have 
> to hardwire a label from one part of my program into a remote part...


  sub last_OUTER_if_int {eval "last $_[0]"};

  local $SIG {INT} = sub {last_OUTER_if_int "OUTER"};


Perhaps we should change last/next/redo to act like goto, that they
can have a computed label instead of a fixed one.  ;-)


Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe