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

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

From:
Nathan Torkington
Date:
September 13, 2000 11:03
Subject:
Re: RFC 212 (v1) Make length(@array) work
Message ID:
14783.49421.451461.82028@prometheus.frii.com
Casey R. Tweten writes:
> Leave length() the way it is now and, if one so desires, they may
> override it on there own to use length for getting:

Not that helpful a suggestion for beginners.  They don't know how to
override, or often even how to load a module.  The point is not that
there's already a way to do it, but that the existing way doesn't make
sense.

Scalar context makes sense in:

  if (@a) { ... }

But you have to know the innards of context to understand why you
do this to get the length of an array:

  $a = @b;

All I'm doing is suggesting another way, one that makes more sense for
beginners:

  $a = length @b;

I think we're going to have to see prototypes extended to cope with
functions like this, anyway.  I'll mention this requirement in the
next version of the RFC.

Nat



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