On Wed, Sep 18, 2002 at 10:15:20AM +0200, Dan Sugalski wrote:
> I've been thinking that we do need to have an extra flag to note 
> whether a key element should be taken as an array or hash lookup 
> element. The integer 1 isn't quite enough, since someone may have 
> done a %foo{1} and we only have that in as an integer key.

I agree. Using integer key == array and string key == hash is not
enough imo.  What about a hash that is index by object, not a string.
What about an array that is index by strings ? ie

  my @array is indexed('a'..'z');

So if parrot wants to provide a method for compound keys, then the
HL should be able to specify what type it is expecting each level
to be.

But the question also exists how this flag should be used/checked.

For example, does the op use it to test the PMC type before calling
the method to fetch the contents, or does it just pass it to the
method and let the PMC do what it wants with it.

I would suggest it gets passed to the method as an argument. That
would allow a PMC to be written that does not care how it is accessed.
But it would also allow the PMC class to do something different
depending on how it is accessed.

Graham.

Reply via email to