![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Re^3: Modules to reduce syntax? (joining namespaces)by LanX (Saint) |
on Dec 22, 2021 at 22:28 UTC ( #11139846=note: print w/replies, xml ) | Need Help?? |
You can't get rid of the sigils $%@ in Perl, because of conflicts with barewords which have many other meanings and the many bultin commands which depend on sigils. But this last example of aliasing a list-form and hashref-form \%hsh = $hsh could be simplified, such that the deref -> isn't needed anymore. use Keyword::Simple to define a new command like e.g. var or let and any var %hsh = LIST; is translated to my $hsh = \ my %hsh; %hsh = LIST; This is not too hard to implement, because you don't need to parse LIST in advance (which could be arbitrary Perl code) Like this explicit dereferencing with -> would be "simplified" away. Demo:
Of course that way you'd loose the ability to have $ident and %ident in different namespaces, but that's often considered bad style anyway. And passing of hash-refs, like with function-parameters wouldn't be that easy without additional \ref-operation
because otherwise var couldn't tell if a $scalar is meant to be aliased to a %hash or an @array
tho you might be able simplify the syntax in many cases with
HTH! :) Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|