Re: RFC 57 (v1) Subroutine prototypes and parameters

[email protected] (Jonathan Scott Duff) Tue, 8 Aug 2000 11:55:05 -0500
Newsgroups perl.perl6.language.subs
Message-ID <[email protected]>
On Tue, Aug 08, 2000 at 09:38:22AM -0700, Nathan Wiger wrote:
> > >      foo($x ||= 10, $y ||= 20);
> > 
> > That already has a meaning ...  I tend to favor syntax that doesn't
> > already have meaning 
> 
> It does have meaning, but I think that's a plus. Currently, it doesn't
> actually do anything (even in 5.6):
> 
> perl -e '
>   sub foo ($x ||= 20) {     
>       print "x = $x\n";
>   }
>   &foo;
> '
> x =

Er, I thought we were talking about setting named parameters, not 
default values.

	sub foo ($name = 'Fred', $age = 32) {	# defaults
	    # do stuff with $name and $age
	}

	foo('Barney', 31);		# Positional assignment
	foo($age:31, $name:'Betty');	# Named assignment
	foo($age:=31, $name:='Betty');	# Named assignment v2

	foo($age||=31, $name||='Betty');	# NO
	foo($age=>31, $name=>'Betty');		# NO, etc.

-Scott
-- 
Jonathan Scott Duff
[email protected]