<?xml version="1.0" encoding="windows-1252"?>
<node id="1007798" title="Re: new keyword &quot;size&quot; to avoid scalar trap ? ( scalar @array != scalar(LIST) )" created="2012-12-07 12:06:48" updated="2012-12-07 12:06:48">
<type id="11">
note</type>
<author id="616540">
moritz</author>
<data>
<field name="doctext">
&lt;p&gt;&lt;c&gt;size&lt;/c&gt; is a terrible name, because it doesn't imply any unit. It could stand for string length in characters, string length in bytes, used memory, number of allocated elements in a container, number of actual elements in a container or any other size you can think of.&lt;/p&gt;

&lt;p&gt;It makes sense to you now because it's not too bad in the mental context you are in, but from the outside it's not good.

&lt;p&gt;Anyway, if you don't fiddle with prototypes at all, the argument list of a subroutine is automatically in list context, so you can just write

&lt;code&gt;
sub elems { scalar @_ }
&lt;/code&gt;

&lt;p&gt;and don't need a new keyword at all.

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-616540"&gt;
[http://perl6.org/|Perl 6 - the future is here, just unevenly distributed]
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1007787</field>
<field name="parent_node">
1007787</field>
</data>
</node>
