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

Re: RFC 23 (v5) Higher order functions

Thread Previous | Thread Next
From:
Damian Conway
Date:
September 19, 2000 20:49
Subject:
Re: RFC 23 (v5) Higher order functions
Message ID:
200009200349.OAA00304@indy05.csse.monash.edu.au
   > Let me ask you:
   > 
   > 	foo('a','b', 'c')
   > 
   > Is 'b' the 1st parameter or the 2nd?

This is the classical mistake of confusing indices and ordinals.
The 1st argument is bound to the parameter whose index is [0],
The 2nd argument is bound to the parameter whose index is [1], etc.

So, yes, 'b' is obviously the second argument when we're speaking
in ordinal. But it is accessed as $_[1] (or ^1) when we're writing Perl.


   > And when a newbie, not one of the oldtimers whose been part of
   > perl6 since Damian's RFC came out. Would they think that the second
   > and third arguments were added or the first and second?

Assuming they've read L<perlcurry>, they'll know that ^1 is $_[1] is
parameter [1] is the 2nd parameter. They'll know because at the very start
of L<perlcurry> I will write:

        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]
        ^1 means $_[1], NOT $_[0]

:-)

Damian

Thread Previous | Thread Next


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