more useful options | |
PerlMonks |
Re^2: Unifying namespaces of @name and $name to simplify dereferencing?by LanX (Saint) |
on Mar 25, 2016 at 18:47 UTC ( [id://1158791]=note: print w/replies, xml ) | Need Help?? |
Hello Eily, Thanks for meditating! =) > There would be a collision issue if you had both a hash and an array with the same name, well already an immediate compile time error, just take the first two lines of Tux suggestion:
translated to
and even if my $name = \%name; comes from an upper scope, one could think about emitting a warning after defining my @name in a lower scope. (But yes we would have overlaps from all namespaces, the title of this thread is too simplistic.) > In the end, your proposition is just a trick to emulate the sigil invariance of perl 6 isn't it? not really, it's another way to address the same question, but I'm looking for a way which does less sacrifices to Perl5 mechanisms like context and could be easily implemented. Perl6 does not only a complete break to backwards compatibility, but has to redesign context and other stuff completely. > think they understand what's happening when you write my $array = ["Hello", "World"]; print $array[0]; well if $array is an alias of \@array they would not only think to understand what is happening, the knew what is happening, because $array[0] and $array->[0] would do the exactly same thing. > with bugs sometimes appearing when people use it in list context without understanding what list context is. I'm not trying to eliminate list context, one would still need to understand what @arr = (@arr1,@arr2) does. But yes,it would be much easier for beginners before getting there (e.g. when coming from JS)
Cheers Rolf
In Section
Meditations
|
|