Re^2: Unifying namespaces of @name and $name to simplify dereferencing?by LanX (Archbishop)
|on Mar 25, 2016 at 19:37 UTC||Need Help??|
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
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.
¹) not sure about the best syntax, but both possibilities can't conflict with older code because they are illegal ATM.
... Other suggestions?