Since this is coming back up, and a ref's in order...
The way keyed access is supposed to work is this.
A key structure is an array of three things:
1) A key
2) A key type
3) A 'used as' type
The key can be an integer, string, or PMC, and is, well, the key. The
thing we use to go looking up in an aggregate.
The key type notes the type of a key -- whether it's an integer, a
string, or a PMC. Nothing at *all* fancy, basically a "what thing is
in the key union slot".
The 'used as' type indicates whether this key is to be used to do a
by-integer-index (array) access or by-string-index (hash) access.
So, code like:
$a{'foo'}
would generate a key struct that looks like:
'foo'
string
as-hash
while $a['foo'] generates:
'foo'
string
as-integer
and $a{$b} generates
$b
PMC
as-hash
and $a{3} generates
3
integer
as-hash
*If* a PMC supports it, it may complain if the basic type is
incorrect (that is, you pass in a string for array access) but
generally that's a bad thing -- the PMC should just convert. (All the
languages we care about do this, as far as I know)
Keys are multidimensional -- that is, we support real
multidimensional arrays, hashes, arrays of hashes, hashes of arrays,
and so on. That means BASIC code like:
A[1,2,3]
generates a key that looks like:
1
integer
as-integer
2
integer
as-integer
3
integer
as-integer
and perl code like:
$a{'a'}[2]{$b}
*should* get you a structure like:
'a'
string
as-hash
2
integer
as-integer
$b
pmc
as-hash
It is *perfectly* valid to pass in a multidimensional key to a
one-dimensional aggregate, or an n+m dimensional key to an
n-dimensional aggregatge. In that case the aggregate *must* consume
as much of the key as it can, use that to fetch out a PMC, and then
make a keyed access call to the resulting PMC with the remainder of
the key structure. (Those of you old-timers who remember, this is why
the key stuff was done as a singly-linked list once upon a time)
This scheme is fairly straightforward and has the advantage of
allowing true multidimensional data structures (which we really want
for space efficiency) and still handling the more legacy
one-dimensional aggregates of references scheme that, say, perl 5
uses.
--
Dan
--------------------------------------it's like this-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk