develooper Front page | perl.perl6.language | Postings from July 2005

Re: Strange interaction between pairs and named binding

Thread Previous | Thread Next
Brent 'Dax' Royal-Gordon
July 18, 2005 15:49
Re: Strange interaction between pairs and named binding
Message ID:
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?

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...

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.

Brent 'Dax' Royal-Gordon <>
Perl and Parrot hacker

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About