Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-07 05:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls