On Tue, 2003-01-28 at 11:49, Dan Sugalski wrote:
> At 8:47 AM +0000 1/28/03, Piers Cawley wrote:
> >Damian Conway <[EMAIL PROTECTED]> writes:
> >  > Sure. But then is this:
> >>
> >>    $ref[$key]
> >>
> >>  an array or hash look-up???
> >
> >Decided at runtime?
> 
> How? People use strings as array indices and ints/floats as hash 
> indices, and count on autoconversion to Make It Work.

And it would. I'm not on one-side or another here, but I do see the
proposal working just fine.

        $ref.fetch($key)

works even when $key is a string and $ref is an ARRAY ref.

        $ref[$key]

is shorthand for

        $ref.[$key]

which is in turn shorthand for

        $ref.fetch($key)

and/or

        $ref.store($key)

depending on how it's used.

Allowing $ref to be a hash reference doesn't change anything because
HASH's fetch and store methods (no matter how builtin or pre-optimized
they may be) will do the conversion.

You still need C<{}> vs. C<[]> for anonymous types, but I don't think
you NEED them for indexing. Now the question becomes, do you WANT them
for readability?

-- 
Aaron Sherman <[EMAIL PROTECTED]>
This message (c) 2003 by Aaron Sherman,
and granted to the Public Domain in 2023.
Fight the DMCA and copyright extension!


Reply via email to