develooper Front page | perl.perl6.internals | Postings from December 2001

Re: Key stuff for aggregates

Thread Previous
From:
Jeff G
Date:
December 4, 2001 21:54
Subject:
Re: Key stuff for aggregates
Message ID:
3C0DB61C.CD728D0D@speakeasy.net
Dan Sugalski wrote:
> 
> 'Kay, here's the preliminary assembly-level docs for keys, which is how
> we're going to be accessing entries in aggregates.
> 
> --------------Snip here---------------
> =head2 Key operations
> 
> Keys are used to get access to individual elements of an aggregate
> variable.  This is done to allow for opaque, packed, and
> multidimensional aggregate types.
> 
> A key entry may be an integer, string, or PMC. Integers are used for
> array lookups, strings for hash lookups, and PMCs for either.
> 
> =over 4
> 
> =item new_key Sx

The fact that the S registers are in fact generic struct registers is
not evident from outside the internal code. For those of us implementing
instructions, it might be useful to explicitly cast values like $1 to
the correct type, in order to make sure we recognize this.

The following code came up frequently when writing the key() functions
that Dan enumerated int his file...

key_inc(interpreter, $1, $2);
Explicitly casting $1 to (KEY*) helps reinforce this fact, eliminates a
compile-time warning, and doesn't cost any runtime penalty.

--
Jeff <jgoff@speakeasy.net>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About