Thanks for meditating! =)
I like the idea of sigil less variables, but I doubt this is feasible in Perl, cause there are too many cases where context matters, so you can't avoid @ and % to denote it...
... like in %settings = (%defaults, %arguments)
Perl without sigils would be a kind of JavaScript (which isn't bad, just very reduced)
I always thought of sigils as a way to spare me of Hungarian notation, in order to understand which type a variable has.
Also sigils help avoiding namespace collisions with builtins, like in $length .
> As it stands, mixing arrays and lists come with many nasty pitfalls.
That's why I was meditating about a very simple change, to implicitly replace any my @arr; with my @arr;my $arr = \@arr; .
This could be implemented easily (e.g. macro mechanism) and the effects are obvious.
Though I was naive with the vice versa part, because my $var could be any datatype, so aliasing my @var to @$var wouldn't be obvious.
And one of the most important use cases is passing data structures around, so my $arr = shift would cause a dangerous ambiguity when forcing an automatic alias.
Though an extended syntax like sub foo { my $arr[] = shift; ... } (or my \@arr = shift ) might solve this and implicitly alias @arr (or $arr respectively).
I'm just realizing that something like my $arr[] = shift has an extra benefit of allowing runtime errors if the wrong type is passed to $arr, while writing my $arr = shift would allow to pass whatever you want. :)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
PS: As a side note:
I was once meditating of adding new sigils for €arrrefs and £hashrefs but this is not only problematic with character encodings but also with keyboard designs.
Just think of The Damians suggestion of appending _ref to each $name. What I do is to prepend $a_... , $h_... , $c_...' . This could be avoided if we had sigils for those references.
In reply to Re^2: Unifying namespaces of @name and $name... (bare lexicals)
by LanX
in thread Unifying namespaces of @name and $name to simplify dereferencing?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |