Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

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

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

Hello Shmem

Thanks for meditating! =)

> This would allow either the association of $identifier with @identifier or %identifier, but not both

yes I was sloppy with the "vice versa" part in my OP.

> To allow both, hashes and arrays have to collapse into one data structure,

No, no, no that is not my intention.

Perl has the advantage that $identifier is an universal untyped scalar which can hold any string, number or reference.

I'm understanding now that for the reverse direction (assigning a ref) we'd need a declaration clarifying the type, this could be

my $identifier[] = [1,2,3]


my \@indentifier = [1,2,3]

, both¹ with the same effect of aliasing $indentifier to \@indentifier

So using something like

my ( $name, \@name, \%name ) = @_
would cause 2 redeclaration errors at compile-time because $name is already taken, so no need for a unifying data structures like in PHP, it's just an aliasing trick to simplify syntax of common data structures.

Besides this opens the possibility of run-time checking of assigned data types and consequently further OP-code performance optimizations.

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

¹) not sure about the best syntax, but both possibilities can't conflict with older code because they are illegal ATM.

... Other suggestions?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2019-11-15 10:03 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (82 votes). Check out past polls.