Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by LanX (Saint)
on Mar 25, 2016 at 19:37 UTC ( [id://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]

and/or

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

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-24 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found