On Tue, Jul 19, 2005 at 12:25:02PM +0800, Autrijus Tang wrote:
: On Mon, Jul 18, 2005 at 03:48:55PM -0700, Brent 'Dax' Royal-Gordon wrote:
: > Autrijus Tang <[EMAIL PROTECTED]> 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?
: > 
: > How much violence would be done to the language if we declared that
: > block (i.e. closure with no "sub" keyword) parameters defaulted to
: > Item|Pair, while sub parameters defaulted to plain Item?  I can't
: > imagine named arguments are going to be used very often on blocks,
: > which tend to be things like loop bodies...
: 
: If the Bare code object (including pointy and non-pointy) default their
: parameter types to "Any" (that is, Item|Pair|Junction), then all of
: these would work:
: 
:     for [1..10].pairs { say(.value) }
:     for [1..10].pairs { say($^x.value) }
:     for [1..10].pairs -> $x { say($x.value) }
:     for 1|2, 3|4 { say(.values) }
:     for 1|2, 3|4 { say($^x.values) }
:     for 1|2, 3|4 -> $x { say($x.values) }

I dunno.  I'm inclined to say that it should default to Item|Pair, and
let people say Any explicitly if they really want to suppress autothreading.
Otherwise conditionals and switches are going to behave oddly in the
presence of "accidental" junctions.

Alternately we could try to distinguish explicit pairs from generated
pairs, and require explicit pairs (or * marked generated pairs) to
transition to the named zone.

Larry

Reply via email to