I think I remember reading one of the comments in the IMCC compiler
something to the effect of "if someone needs N keys they can just
convert to strings."
Sorry I can't find the exact wording right now, but it might point you
somewhere useful.

Amos Robinson

On 1/21/06, Klaas-Jan Stol <[EMAIL PROTECTED]> wrote:
> Matt Fowles wrote:
>
> >Klaas-Jan~
> >
> >On 1/20/06, Klaas-Jan Stol <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Hi,
> >>
> >>I tried to index aggregates using several types of keys (that is,
> >>several types of values), and it seems only string and integer values
> >>can be used as keys. A quick look at the source in
> >>compilers/imcc/symreg.c confirms this, there is no case for 'N' values
> >>(and a test makes Parrot say build_key: unknown set).
> >>
> >>Will it be possible to use floating points as keys for arrays? It's up
> >>to the PMC to implement the indexing correctly, so support for this by
> >>IMCC should be no problem, I think.
> >>
> >>(I vaguely remember myself asking this sort of question before, quite
> >>some time ago, but I couldn't find it anywhere in the mail archives --
> >>sorry about that)
> >>
> >>The reason for this question is LuaTable PMC, which can be used as both
> >>an array as well as a Hashtable. I'd like to implement proper Lua Table
> >>behaviour into the LuaTable PMC, but it should be able to cope with code
> >>like this:
> >>
> >>    $P0 = new .LuaTable
> >>    $P1 = new .LuaNumber
> >>    $P1 = 42
> >>    $P0[1.234] =  $P1
> >>
> >>And this currently doesn't work, as mentioned above. (According to the
> >>PDD on keys, it should be possible to do this:
> >>
> >>        op arg, P1[12.34] # Constant number key - handled as constant key
> >>
> >>
> >
> >I am not sure how wise an idea this is given the difficult of
> >comparing floating point numbers for equality.
> >
> >
> You may be right, but nevertheless, that's the problem of the
> language/pmc implementer (me, in this case). And, if Lua can do it, it
> should be possible for me to do it as well.
>
> klaas-jan
>

Reply via email to