On Tue, 08 Aug 2000 10:14:53 -0700, Nathan Wiger wrote:
>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.
Getting there, but with some nasty catches.
A) as it is now, ||= has a meaning. If it was the proper meaning, I
wouldn't mind at all.
code snippet:
$a ||= 'default';
result
$a before after
'any true value' 'any true value'
123.45 123.45
undef 'default'
All dandy. But:
0 'default'
'' 'default'
Oops.
That would imply that with
sub foo ($age ||= 32) { ... }
foo($age : 0 );
that $age would become 32. EVIL. Not what I want.
Now, with the proposed (and reject :-( ) ?? operator, which would only
continue if the left hand side was defined (not necessarily just true),
this would have worked well.
B) I would expect
foo($name = 'Fred', $age = 32);
that $name and $age would be set, but *here and now*, in the scope of
the function call, not in the scope of the function body.
--
Bart.