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?