Ticket #1053 (closed todo: done)

Opened 5 years ago

Last modified 5 years ago

[TODO] Allow Parrot Hashes to have PMC keys

Reported by: bacek Owned by:
Priority: normal Milestone:
Component: configure Version: trunk
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

Originally created at  http://rt.perl.org/rt3/Ticket/Display.html?id=54236

As seen in 54220, I discovered to my chagrin that not only do Parrot hashes have only string keys, that trying to pull the keys out as PMCs (presumably Strings) fails.

Aside from the ugly failure, this design seems broken in the face of languages like Perl6 that expect to be able to use non-string hash keys. Both for direct use by Perl6 internals, and for interoperability with other languages, it seems like at least one core Parrot hash class should use PMC keys. These should be either readable directly as PMCs, or stringified if assigned to a string register. (This latter case may be optimized if the key PMC is a String, of course, but that's a different issue).

This ticket can be considered in some sense the converse of 54220. That ticket asks that ordinary string keys be extractable as String PMCs, whereas this one asks that general PMC keys work, and that they stringify if extracted as ordinary strings.

-'f

Change History

Changed 5 years ago by bacek

This is easy to implement in few steps:

1. Add VABLE_hashvalue function.

2. Add Default.hashvalue to stringify SELF and calculate hash.

3. Add Integer.hashvalue and String.hashvalue.

4. Adjust Parrot_Hash to use VTABLE_hashvalue for PMC keys.

-- Bacek

Changed 5 years ago by bacek

... and if no one beats me I'm going to implement it over weekend.

-- Bacek

Changed 5 years ago by bacek

  • status changed from new to closed
  • resolution set to done

Ability to use PMC as Hash keys implemented in r41515. Resolving ticket.

Note: See TracTickets for help on using tickets.