|
|
| Perl: the Markov chain saw | |
| PerlMonks |
new keyword "size" to avoid scalar trap ? ( scalar @array != scalar(LIST) )by LanX (Monsignor) |
| on Dec 07, 2012 at 16:40 UTC ( #1007787=perlmeditation: print w/ replies, xml ) | Need Help?? |
|
Hi
I'm meditating if Perl should introduce an explicit keyword size (or count ¹) always return the number of elements of lists and arrays... (length is already taken and scalar is to overloaden) so
and
I know "explicit is better than implicit" is more a Python dogma, but since even popes still fall into the scalar trap we should maybe consider "another way to do it" (best Perl tradition =).
Cheers Rolf PS: I tried to provide an example implementation of size, something like
but was to lazy to fiddle around with prototypes. Anyway IMHO a reliable implementation will need more parsing magic than prototypes can bring to avoid disambiguation. ¹) or whatever
Back to
Meditations
|
|