develooper Front page | perl.perl6.language | Postings from February 2002

Re: proposal: when-blocks, and binding $_

Thread Previous | Thread Next
From:
Austin Hastings
Date:
February 26, 2002 13:53
Subject:
Re: proposal: when-blocks, and binding $_
Message ID:
20020226215246.22229.qmail@web12301.mail.yahoo.com
Which, then, would you like:

To implicitly localize $_, losing access to an outer version,
or to have to change between implicit and explicit operations?

for @A {
  for @B -> $x {
    when /a/ { s/x/y/; }
  }
}

What should that do?

=Austin

--- Allison Randal <al@shadowed.net> wrote:
> On Tue, Feb 26, 2002 at 01:26:41PM -0800, Austin Hastings wrote:
> > 
> > Possibility B- when-blocks accept a -> operator, which if used
> "naked"
> > binds the current localizer to $_.
> 
> I think if I had a choice between
> 
> given $y -> $x {
> 	when /a/ -> {...}
> 	when /b/ -> {...}
> 	...
> }
> 
> and
> 
> given $y {
> 	when /a/ {...}
> 	when /b/ {...}
> 	...
> }
> 
> I'd always prefer the second. Re-aliasing the aliased variable for
> every
> when block doesn't quite seem worth the effort.
> 
> Allison


__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About