Just my two cents then back to lurking. The idea of having named parameters 
with different names than the variables ++. Otherwise your public API is 
dependent on private variables which is a Bad Thing and the only thing that 
realy bugged me about current named parameters in P6.

BTW why is it that just because they are defined as named they can't be used 
positionaly as well?

Guess you could always use your same positional to named magic for the 
positionals. Then the programmer is expliciting defining the order in case 
the cases they want to use ordered versus named.

multi sub seek ( $x, $y ) { seek( $:x, $:y) }:
multi sub seek ( :x($horizontal), :y($vertical)) { ... };

On 8/19/05, Larry Wall <[EMAIL PROTECTED]> wrote:
> 
> On Fri, Aug 19, 2005 at 08:39:24AM -0700, Larry Wall wrote:
> : Actually, that's an argument that : is in a different class than the 
> regex
> : quantifiers, and required named should be
> :
> : sub bar (+$:key)
> :
> : as I speculated earlier. Maybe we just force that to bind to $key 
> instead
> : of $:key.
> 
> Which makes me wonder whether, in ordinary code (not sigs)
> 
> $:key
> 
> is short for
> 
> :key($key)
> 
> The idea being that it makes it really easy to pass delegate particular
> pairs to subfunctions as long as you keep the names consistent. It'd
> also make it drop-dead easy to write positional-to-named constructors:
> 
> method new ($proto: $a, $b, $c) {
> ...
> return $proto.bless($:a, $:b, $:c);
> }
> 
> instead of
> 
> method new ($proto: $a,$b,$c) {
> ...
> return $proto.bless(:a($a), :b($b), :c($c));
> }
> 
> I suppose if we pushed it we could even allow $:foo in adverbial position.
> 
> 1 .. 100 $:by
> 
> But I wonder if people will think that
> 
> foo 1, 2, 3, @:foo
> 
> should interpolate @foo as a list of pairs rather than binding to the
> 'foo' argument. Likewise for %:bar. But those are still [EMAIL PROTECTED] and
> *%bar, I suspect, and people can learn that the : twigil always means
> rewrite. Hmm. That seems to indicate that the actual signature for
> named parameters is
> 
> sub foo (:foo($foo))
> 
> and that
> 
> sub foo ($:foo)
> 
> is just shorthand for that. That would give us the ability to give the
> variable a different name than the parameter. I like.
> 
> sub seek (:x($horizontal),:y($vertical))
> 
> On the other hand, it's now unclear whether you can call that as 
> seek(1,2).
> Needs to be allowed somehow.
> 
> Larry
> 



-- 
__________
Eric Hodges

Reply via email to