Garrett Goebel <[EMAIL PROTECTED]> writes:
> Piers Cawley wrote:
>> Garrett Goebel <[EMAIL PROTECTED]> writes:
>> >
>> > What was the reason again which Larry rejected unifying the
>> > syntax for array and hash indexing? As Piers said, we know
>> > whether $a is an array or hash reference when we do:
>> >
>> > print $a->{foo};
>>
>> But as someone else pointed out, there may be classes that have both
>> hashlike and arraylike interfaces. For instance:
>>
>> my $queue = SomeQueue.new;
>>
>> $queue.push('foo');
>> $queue.push('bar');
>> $queue.push('baz');
>>
>> my $index_of_foo = $queue{'foo'}; # undef if no foo in queue.
>
> And what's to prevent that collection object from handling:
>
> my $queue = SomeQueue.new;
>
> $queue.push('foo');
> $queue.push('bar');
> $queue.push('baz');
>
> my $index_of_foo = $queue['foo']; # undef if no foo in queue.
Because I also want to be able to access
$nth_foo = $queue[$n]
Which I thought was so blindingly obvious as not to need stating.
--
Piers