Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Rosetta PGA-TRAM

by moritz (Cardinal)
on Jun 17, 2009 at 22:42 UTC ( #772565=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Rosetta PGA-TRAM
in thread Rosetta PGA-TRAM

Why does the block use $^a in one place (the automatic parameter) and $a in another place? Shouldn't that be a different (undeclared) variable? (Likewise for b).

No, the ^ twigil is only necessary in the first occurrence. That was introduced because things like this:

my $block = { my $v = %hash{$^key}; say "The lookup {%hash{$^key}} yields $v"; };

Would complain about the closure inside the string getting no argument, because $^key was interpreted as a formal parameter to the inner-most closure, which in this case was the one inside the string.

Or more general, you couldn't refer to outer lexicals that happened to be self-declaring formal parameters.

So it was decided that after $^foo occurred once, you could refer to it as $foo to, disambiguating it in inner blocks.

Comment on Re^3: Rosetta PGA-TRAM
Select or Download Code
Replies are listed 'Best First'.
Re^4: Rosetta PGA-TRAM
by John M. Dlugosz (Monsignor) on Jun 17, 2009 at 22:56 UTC
    I see. I must have overlooked that when I read through the diffs with the last version I studied carefully. It's so easy to overlook changed or especially removed things!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://772565]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2015-11-30 17:10 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (777 votes), past polls