Dan Sugalski wrote:
> Gordon Henriksen wrote:
>
> > Leopold Toetsch wrote:
> >
> > > Gordon Henriksen wrote:
> > >
> > > > ... Best example: morph. morph must die.
> > >
> > > Morph is necessary. But please note: morph changes the vtable of
> > > the PMC to point to the new data types table. It has nothing to do
> > > with a typed union.
> >
> > The vtable IS the discriminator. I'm referring to this:
> >
> > typedef union UnionVal {
> > struct { /* Buffers structure */
> > void * bufstart;
> > size_t buflen;
> > } b;
> > struct { /* PMC unionval members */
> > DPOINTER* _struct_val; /* two ptrs, both are
> > defines */
> > PMC* _pmc_val;
> > } ptrs;
> > INTVAL int_val;
> > FLOATVAL num_val;
> > struct parrot_string_t * string_val;
> > } UnionVal;
> >
> > So long as the discriminator does not change, the union is
> > type stable.
>
> The vtable's not the discriminator there, the flags in the pmc are
> the discriminator, as they're what indicates that the union's a
> GCable thing or not. I will admit, though, that looks *very*
> different than it did when I put that stuff in originally. (It used
> to be just a union of FLOATVAL, INTVAL, and string pointer...)
Hm. Well, both are a discriminator, then; dispatch to code which
presumes the contents of the union is quite frequently done without
examining the flags. Maybe use a VTABLE func instead to get certain
flags? i.e.,
INTVAL parrot_string_get_flags(..., PMC *pmc) {
return PMC_FLAG_IS_POBJ + ...;
}
Then, updating the vtable would atomically update the flags as well.
Or, hell, put the flags directly in the VTABLE if it's not necessary
for them to vary across instances.
I have the entire source tree (save src/ tests) scoured of that rat's
nest of macros for accessing PMC/PObj fields, but I broke something and
haven't had the motivation to track down what in the multi-thousand-
line-diff it was, yet. :( Else you'd have the patch already and plenty
of mobility in the layout of that struct. Near time to upgrade my poor
old G3, methinks; the build cycle kills me when I touch parrot/pobj.h.
Do any PMC classes use *both* struct_val *and* pmc_val concurrently? I
was looking for that, but am afraid I didn't actually notice.
--
Gordon Henriksen
IT Manager
ICLUBcentral Inc.
[EMAIL PROTECTED]