develooper Front page | perl.perl6.language.subs | Postings from September 2000

Re: RFC 212 (v1) Make length(@array) work

From:
merlyn
Date:
September 13, 2000 11:46
Subject:
Re: RFC 212 (v1) Make length(@array) work
Message ID:
m1aedci102.fsf@halfdome.holdit.com
>>>>> "Casey" == Casey R Tweten <crt@kiski.net> writes:

Casey> I agree with this line of thinking, however, I suppose I don't
Casey> agree with implementing length in this way since we already
Casey> have C<scalar>.

Casey> In that light, if C<length> is to replace scalar for, we'll
Casey> say, LISTs, then lets remove C<scalar> since it will be
Casey> effectivley defunct.

Uh, no.  It provides a scalar context.  For only a few kinds of things
that return lists in lists context, do they return the LENGTH of that
list in a scalar context.  Most other things have much more
interesting return values in a scalar context, and a few have nothing
but undef.  I just had this discussion on Usenet... please go Deja
comp.lang.perl.misc.  In fact, you can't get "scalar" in front of a
list.  It doesn't exist.  It can't *ever* exist.

This also means that

        length XXXXX

is not the same as

        length scalar XXXXX

but rather, specialcased VERY SPECIFICALLY for

        length @FOO

This is what I don't like about this proposal.  It raises more
eyebrows than it fixes.  I like the suggestion that it be a warning,
and leave it at that.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About