On Tuesday, January 7, 2003, at 02:05 PM, Deborah Ariel Pickett wrote:
Indeed, Larry mentioned a while back that C<.length> for arrays might be spelled C<.elems> or something, for that exact reason -- the term "length" is horribly ambiguous when you're using it on a scalar (string) value, when you've got Unicode (you need to be saying "chars", or "bytes", or "elems", or whatever), and so maybe the word should change for arrays as well.Getting off topic here (a bit), but I think it's a Mistake to haveOn 2003-01-07 at 11:31:13, Mr. Nobody wrote:.length is unneeded, since an array gives its length in numeric context, so
you can just say +@a.
Unneeded, but harmless.
.length mean different things on an array ["Number of elements"] and a
(string) scalar ["number of characters"]. While there will never be any
confusion on the part of Perl, it'll promote Thinking About Things The
Wrong Way among Perl novices, who will try to think of strings as C-like
arrays of characters. We've gone to great lengths to disabuse people of
that notion in Perl5; let's keep it that way.
Perhaps .size for number-of-elements and .length for length-of-string
would work?
Not sure what was decided on that particular one, if anything. We need to confirm. IIRC, C<.length> likely won't exist at all for strings. It still might exist (?) for arrays.
MikeL