> 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) { ... }
# Assignment
foo('Barney', 31); # Positional assignment
foo($age = 31, $name = 'Betty'); # Named assignment
Seems to make alot more sense and be more consistent to me. We would
just have to add a single rule: anything inside a sub's () becomes
auto-my'ed for the sub. No new syntax, just a clarification of the
existing one.
-Nate
- Re: RFC 57 (v1) Subroutine prototypes and par... Jacob Davies
- 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
