Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion PerlHash using PMCs for keys?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Leopold Toetsch  
View profile  
 More options Jun 4 2004, 4:58 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Fri, 4 Jun 2004 10:58:51 +0200
Local: Fri, Jun 4 2004 4:58 am
Subject: Re: PerlHash using PMCs for keys?

Piers Cawley <pdcaw...@bofh.org.uk> wrote:
> Leopold Toetsch <l...@toetsch.at> writes:
>> Just use a Key PMC for $P2.
> So, just for fun I added the following test to t/pmc/perlhash.t:
>     new P10, .PerlHash
>     new P1, .PerlString
>     set P1, "Bar"
>     new P2, .Key
>     set P2, P1

      ^^^

C<set Px, Py> aliases the two PMCs, both are pointing to the same PMC
then. You'd like to use C<assign> here.

>     new P3, .Key
>     set P2, P1

          ^^
typo?

> Perl 6 supports using full on objects as keys in its hashes. It seems
> that having parrot do the same would be a Good Thing.

The main problem here is, what does ...

  set P0, P1[P2]

... mean: keyed_string or keyed_integer, i.e. hash or array lookup.
The Key PMC provides this information, a plain string could be used in
both ways:

  set P2, "42"
  set P0, P1[P2]

It depends of course on the aggregate, what kind of key it would like to
use, but e.g. for an OrderedHash PMC, which supports lookup by string
*and* by integer, the usage is ambiguous.

We could change C<key.c:key_integer()> to extract a number with
C<get_integer> from any PMC and do the same with C<key_string> but some
keyed usage needs a defined type.

leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.