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) } > Right now one of my biggest Perl 6 nits is that the combination of > subroutines everywhere and the Pair type's special role in subroutine > dispatch makes Pairs a real pain to work with. This would help to fix > the problem without creating a new SuperPair type or something > similarly silly. Seconded. Thanks, /Autrijus/
pgpxMSflL0GBA.pgp
Description: PGP signature