On Fri, Mar 29, 2002 at 10:28:09AM -0800, Brent Dax wrote:
> Let's say my data pointer points to this struct:
> 
>       typedef struct parrot_subroutine_t {
>               opcode_t *bytecode;
>               STRING   *name;
>               proto    *prototype;
>               (a bunch of other stuff here)
>       } Subroutine;
> 
> Now, most of the time, I'll just want to access the bytecode.  I can
> remove a level of indirection by stuffing the bytecode pointer into
> cache.struct_val.
> 
> The cache.* is intended to just be *shortcuts* to commonly-accessed
> data, *not* pointers to completely different data.  That's why it's
> referred to as a "cache".

Thank you for that description. I've been struggling for a long time
to figure out the meaning of ->data vs ->cache. I think I initially
assumed exactly what you said, but existing usage is nowhere close to
what you describe. But now that you said it, your statement is
obviously correct. It's the code that's wrong.

Which means the definition of KEY_PAIR is wrong. It contains a cache
member that is anything but a cache -- it's the actual data.

Would anyone object if I added

  typedef union {
     INTVAL int_val;
     FLOATVAL num_val;
     STRING *struct_val;
     PMC *pmc_val;
     void *ptr_val;
  } UNIONVAL;

and changed everything to using it instead of having several of the
identical union scattered around? (pmc->cache, key_pair->cache,
Stack_entry->entry,...)

Or are we switching to MixedCase, so it should be UnionVal. Or maybe
just Val? ANYVAL/AnyVal? VALUE/Value?

Reply via email to