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

Re: Strange interaction between pairs and named binding

Thread Previous | Thread Next
From:
Brent 'Dax' Royal-Gordon
Date:
July 18, 2005 15:49
Subject:
Re: Strange interaction between pairs and named binding
Message ID:
b8b9a51105071815486c8a38dd@mail.gmail.com
Autrijus Tang <autrijus@autrijus.org> 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 <brent@brentdax.com>
Perl and Parrot hacker

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About