At 11:46 PM 8/31/00 +0200, Bart Lateur wrote:
>On Fri, 1 Sep 2000 07:27:24 +1100 (EST), Damian Conway wrote:
>
> > > > And has anyone pointed out that C<list> is just:
> > > >
> > > > sub list {@_}
> > >
> > > Um no. I would expect it to be
> > >
> > > sub list { @_[0..$#_] }
> >
> >It's too early in the morning.
> >The subtlety here escapes me.
>
>It's the difference between an array and a list.
>
> sub array { @_ }
> sub list { @_[0..$#_] }
> @a = qw(a b c);
> $\ = "\n"
> print scalar array @a;
> print scalar list @a;
>-->
> 3
> c
I guess this is due to the combination of:
1. Context reaches down through stack frames to find its victim^Wargument
2. Arrays in a scalar context evaluate to their number of entries
3. Array slices evaluate to the list of their members
Each one is reasonable, but boy, put them together and you can trip up even
the wiley Antipodean Perl master (albeit in a chronically challenged
state... so to speak).
This is the kind of thing that keeps Perl instructors in business...
--
Peter Scott
Pacific Systems Design Technologies
- RFC 175 (v1) Add C<list> keyword to force list c... Perl6 RFC Librarian
- Re: RFC 175 (v1) Add C<list> keyword to for... skud
- Re: RFC 175 (v1) Add C<list> keyword to... Nathan Wiger
- Re: RFC 175 (v1) Add C<list> keyword to for... Damian Conway
- Re: RFC 175 (v1) Add C<list> keyword to... Nathan Wiger
- Re: RFC 175 (v1) Add C<list> keyword to... Graham Barr
- Re: RFC 175 (v1) Add C<list> keywor... John Porter
- Re: RFC 175 (v1) Add C<list> keyword to... Damian Conway
- Re: RFC 175 (v1) Add C<list> keywor... Bart Lateur
- Re: RFC 175 (v1) Add C<list> ke... Peter Scott
- Re: RFC 175 (v1) Add C<list> keyword to... Damian Conway
- Re: RFC 175 (v1) Add C<list> keywor... Tom Christiansen
- Re: RFC 175 (v1) Add C<list> ke... Steve Fink
- Re: RFC 175 (v1) Add C<list&g... Graham Barr
- Re: RFC 175 (v1) Add C<list&g... Tom Christiansen
- Re: RFC 175 (v1) Add C<list> ke... Nathan Wiger
- Re: RFC 175 (v1) Add C<list&g... Tom Christiansen
- Change "($one, $two)=&q... Nathan Wiger
- Re: Change "($one, ... Tom Christiansen
- Re: Change "($one, ... Nathan Wiger
