in reply to Re: new keyword "size" to avoid scalar trap ? ( scalar @array != scalar(LIST) )
in thread new keyword "size" to avoid scalar trap ? ( scalar @array != scalar(LIST) )
hmm good point...
you are forcing everything into an array,
maybe
is easier to read.sub size { scalar @_ }
it's like explicitly wrapping lists and arrays into scalar @{[ ... ]}
But w/o prototypes this would mean to copy huge arrays around...
And something like size %hash couldn't be extended to find scalar keys %hash.
Anyway your example fits as a proof of concept! =)
(But an efficient implementation should be done in XS. Edit: see benchmark)
Cheers Rolf
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: new keyword "size" to avoid scalar trap ? ( scalar @array != scalar(LIST) )
by tobyink (Canon) on Dec 07, 2012 at 22:33 UTC |
In Section
Meditations