On Fri, Sep 09, 2005 at 08:02:32PM +0200, Ingo Blechschmidt wrote:
: Hi,
: 
:     # Should this work?
:     say (a => 1, b => 2)<b>;  # 2 or error?
: 
:     # Similarily:
:     my @array = (a => 1, b => 2);
:     say @array<b>;
: 
:     my $arrayref = [ a => 1, b => 2 ];
:     say $arrayref<b>;
: 
: FWIW, I think accessing arrays and arrayrefs by key should probably not
: work, but I'm unsure on (...)<b>.

Well, conservatively, we don't have to make it work yet.  But I suspect
the code to do it will already be in there somewhere, considering that's
more or less how I've proposed searching named arguments to bind to
positionals.  In other words, when you say

    sub foo ($a, $b) {...}

and call it as

    foo(0, a => 1, b => 2, %defaults)

then at the point where it is trying to decide what to bind to $b, it's
essentially doing

     (a => 1, b => 2, %defaults)<b>

That's assuming it's not actually worth building the temp hash, and that
you want $a to end up 0 and ignore the 1.

Larry

Reply via email to