On Tuesday, March 25, 2003, at 02:19 PM, Damian Conway wrote:
And I don't think that allowing 20 different types of assignment in
the parameter list of a subroutine actually helps at all. Especially
since the vast majority of parameters in Perl 6 will be constant.
Twenty types of _initialization_. :-D
Seriously, tho, I'm not sure I understand the constantness part.
sub foo($x = 1) {...} # A6 syntax
I read the above as saying $x is indeed constant, but if it's not
explicitly placed by the caller, we're going to pretend the caller
passed us a 1. Likewise, I read
sub foo($x //= 1) {...}
as saying the value stored in $x is a constant, but if the caller
passed an undefined value (or didn't pass anything at all), we're going
to instead pretend they passed us a (still-constant) 1. I'm not sure
why that violates any rules.(?)
As a marginal bonus, perhaps an assertion-style
sub foo($x //= 1) {...}
optimizes to be faster, runtime, than
sub foo($x) { $x //= 1; ... }
when passing a constant in $x, e.g C<foo(5)> or C<foo('BLAH')>, since
it can optimize out the assertion at compile-time?
MikeL
- Re: A6: argument initializations via //=, ||=, ::= Damian Conway
- Re: A6: argument initializations via //=, ||=, ::= Matthijs van Duin
- Re: A6: argument initializations via //=, ||=, ::= Jonathan Scott Duff
- Re: A6: argument initializations via //=, ||=, ::= Damian Conway
- Re: A6: argument initializations via //=, ||=, ::= Jonathan Scott Duff
- Re: A6: argument initializations via //=, ||=, ::= Mark Biggar
- Re: A6: argument initializations via //=, ||=, ::= Michael Lazzaro
- Re: A6: argument initializations via //=, ||=, ::= Paul
- Re: A6: argument initializations via //=, ||=, ::= Damian Conway
- Re: A6: argument initializations via //=, ||=, ::= Paul
- Re: A6: argument initializations via //=, ||=, ::= Michael Lazzaro
- Re: A6: argument initializations via //=, ||=, ::= Damian Conway
- Re: A6: argument initializations via //=, ||=, ::= Michael Lazzaro
- Re: A6: argument initializations via //=, ||=, ::= Damian Conway
- Re: A6: argument initializations via //=, ||=, ::= Smylers
- Re: A6: argument initializations via //=, ||=, ::= Michael Lazzaro
- Re: is static? -- Question arcadi shehter
- Re: is static? -- Question Matthijs van Duin
- Re: is static? -- Question arcadi shehter
- Re: is static? -- Question Matthijs van Duin
- Re: is static? -- Question arcadi shehter