Alex Francis wrote:
> I finally got round to reading a little about Perl 6 - Gabor's blog
> post / mailout:
>
> http://szabgab.com/blog/2009/06/1245228625.html
>
> One thing that leapt out to me was this bit:
>
> --quote--
> Instead of the quite ugly $#array notation used in Perl 5 (that
> returns the highest index in the array) fetching the number of
> elements of array is done in Perl 6 by the elems() function. Actually
> I think the object oriented writing is much nicer here:
>     use v6;
>     my @names = <foo bar baz>;
>     say elems @names;                   # 3
>     say @names.elems;                   # 3
> --end quote--
>
> "elems" seems a pretty odd choice of word. Does anyone know why any of
> 'length', 'count' or 'size' wasn't chosen for this?
>
>   
length could refer to a number of properties as could count and size 
also all three are used by lots of other languages. elems is a shortend 
version of elements which describes accurately what the number returned is.

Max
> Maybe there's an archived discussion somewhere that explains the rationale?
>
> I did find this RFC requesting length( @array ) -
> http://dev.perl.org/perl6/rfc/212.html
>
> Ah... answers own question: http://dev.perl.org/perl6/doc/design/apo/A02.html
>
> Basically, "length" is ambiguous / would require overloading for
> different arguments, hence "elems" is more specific, explicit and less
> likely to be misinterpreted. I still think "count" would have been
> clearer, but hey ho.
>
> Alex
> _______________________________________________
> BristolBathPM mailing list
> [email protected]
> http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm
>   

_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to