perl6-language  

Re: Strange interaction between pairs and named binding

Larry Wall
Mon, 18 Jul 2005 14:33:34 -0700

On Mon, Jul 18, 2005 at 08:42:24PM +0800, Autrijus Tang wrote:
: This currently works in Pugs:
: 
:     for [1..10].pairs -> Pair $x { say $x.value }
: 
: But this does not:
: 
:     for [1..10].pairs -> $x { say $x.value }
: 
: Because the ruling that pairs must not be bound to parameters that are
: not explicitly declared to handle them.  Is this a desirable behaviour?

No, but it's necessary unless we can find some way of breaking the
magical relationship of pairs with named arguments.  Even if we came
up with special syntax on the calling end to differentiate the positional
zone from the named zone, it wouldn't help here, since the call syntax
is implicitly buried in the implementation of "for".  So we have to
distinguish it on the formal end, and currently Pair is the way to do that.

Larry