develooper Front page | perl.perl6.language | Postings from October 2001

Re: Perl 6 - Cheerleaders?

Thread Previous | Thread Next
From:
Damian Conway
Date:
October 29, 2001 14:39
Subject:
Re: Perl 6 - Cheerleaders?
Message ID:
200110292239.JAA23195@indy05.csse.monash.edu.au

Larry revealed:

   > : 	method bar($me : *@_) {
   > : 		...
   > : 	}
   > : 
   > : will use $me instead.
   > 
   > That is the approach I currently favor.  (Though I'd probably leave
   > out the space in front of the colon.)  And it has the advantage that
   > $me is automatically assumed to be read only.


Okay, so let's clarify:

	1. If you declare a method *with* a colon separator in its parameter
	   list:

		method foo ($self: $foosrc, $foodest, $etc) {...}

	   then the parameter before the colon is bound to the invocant,
	   and the parameters after the colon are bound to the other
	   args of the method call.


	2. If you declare a method *without* a colon separator in its
	   parameter list:

		method foo ($foosrc, $foodest, $etc) {...}

	   then the parameters are bound to the non-invocant
	   args of the method call and the invocant itself is 
	   inaccessible (except implicitly through the unary dot
	   operator).

	
	3. If you declare a method *without* any parameter list:

		method foo {...}

	   then the method call arguments (including the invocant?)
	   are bound to @_.


Is that correct?

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