On Tue, Aug 08, 2000 at 10:14:53AM -0700, Nathan Wiger wrote:
> > 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
>
> Wow, I was actually looking at this backwards. Let me brain dump:
>
> # Defaults
> sub foo ($name ||= 'Fred', $age ||= 32) { ... }
Okay, why "||=" there rather than just "="? AFAIK, "sub foo ($a = 1)
{ ... }" doesn't do anything useful in perl now, so we can do with it
what we will in relative impunity.
> foo($age = 31, $name = 'Betty'); # Named assignment
But that already has a meaning that I'd hesitate to take away from the
programmer.
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]
- Re: RFC 57 (v1) Subroutine prototypes and... Bart Lateur
- Re: RFC 57 (v1) Subroutine prototypes... Nathan Wiger
- Re: RFC 57 (v1) Subroutine proto... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine p... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine p... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine prototypes and... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine prototypes and paramet... Chaim Frenkel
- Re: RFC 57 (v1) Subroutine prototypes and parameters H.Merijn Brand
