Aaron Sherman writes:
: On Thu, 2002-03-21 at 12:52, Allison Randal wrote:
: > On Wed, Mar 20, 2002 at 09:59:35AM -0800, Larry Wall wrote:
: > >
: > > I should update y'all to my current thinking, which is that $_ is
: > > always identical to the current topic, even if the topic is aliased to
: > > some other variable. To get at an outer topic, you'd have to use the
: > > same mechanism we'll use for redeclared lexicals:
: > >
: > > my $foo = $OUTER::foo;
: > >
: > > for @x { # aliases $_
: > > for @y -> $y { # aliases both $x and $_
: > > print $OUTER::_;
: > > }
: > > }
: >
: > I rather like this compromise. It provides the desired behaviour of
: > "always default to the current topic" and so eliminates the confusion
: > between C<when> and other defaulting constructs. It also maintains the
: > "$_ is default" concept, which is quite important to people, as earlier
: > bits of this thread demonstrated.
:
: Ok, so am I to take it that you could say:
:
: FOO: for @x {
: BAR: for @y {
: print $FOO::_;
: }
: }
Er, I don't think so.
: Or is OUTER a special-case label?
It's a special case like MY::, and somewhat ugly to discourage you from
using it when you should probably be naming your loop variables.
: Personally, I've always prefered this syntax:
:
: for @x {----\
: for @y { |
: print;<-/
: }
: }
:
: Which is visually appealing and raises coding style arguments to a whole
: new level.
Hmm, tempting.
Larry