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

Re^4: Unifying namespaces of @name and $name to simplify dereferencing?

by LanX (Archbishop)
on Mar 25, 2016 at 19:43 UTC ( #1158796=note: print w/replies, xml ) Need Help??

in reply to Re^3: Unifying namespaces of @name and $name to simplify dereferencing?
in thread Unifying namespaces of @name and $name to simplify dereferencing?

> Update: it is in your model where confusion arises about the type of the passed $name.

yes you are right, $name = shift should do no aliasing automatically, Perl needs universal scalars which are untyped.

see also my other replies, discussing typed my $name[] = ... declarations to be able to pass/assign references which work without -> operator.


> No. The name passed in (update: in normal behavior, obviously) is a string, the $name{...} lookup is into a previously defined hash:

yes and in feature "autoref" this should never compile!

Because of the alias $name = \%name in the upper scope a redeclaration of a simple scalar $name in the sub would make $name{...} accessing an undefined variable.

I.o.W. identifiers must be unique in any scope and you would achieve this compile time checking without needing to use Perl Critic.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2019-11-18 16:23 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (90 votes). Check out past polls.