Alex Gough <[EMAIL PROTECTED]> wrote: > On Thu, 14 Feb 2002, Dave Mitchell wrote: > > > $foo would first be a Dog, then a FireHydrant. When it changed to a > > > FireHydrant the previous contents would get blown away. > > > > Hmmm - how do we distinguish between a plain scalar that is temporarily > > typed, and a 'proper' permanently-typed scalar? > > > > eg in the following > > > > my Dog $spot = Dog.new("waggly tail"); > > $spot = Cat.new(); > > > > you would expect $spot to always remain a dog no matter what, and will > > throw a run-time (or compile time) error if it can't think of a way of > > making itself into a "doggish" cat. > > I think you're thinking at too high a level to make much sense of what > the vtables should be doing. A better example to drive your mind would > be: > > tie $foo, 'Baa'; > $foo = 12; > > In which case the $foo PMC will know that it is somehow tied, and dispatch > control to an appropriate bit of perl code.
Tying is higher-level than I was thinking about. Tying is an easy case: we have a 'tied' vtable type whose assign method looks loosely like void tied_assign(PMC *dst, PMC *src) { call_method(dst, "FETCH", src); } > > > it's current vtable pointer, and if so, under what circumstances > > are we allowed to change the pointer? Do we need a PMC flag saying > > that our type is fixed? And if so, how do we handle > > PMCs define how a variable behaves in different circumstances. We can > change the pointer in every instance except those where the receiving > PMC does not let us, in general a PMC will be happy to lose its > identity. But that doesn't answer my questions, which were essentially: 1. is the Perl-level type of a variable (eg my Dog $spot) implemented at the Parrot level by using the vtable pointer to identify the type? (ie a vtable per Perl type, user-defined or builtin) 2. If so, how do we distinguish between two PMCs, both of whose vtable pointers currently point to the 'Dog' vtable, but one of whom has been delared as type Dog and so should never have it's vatble pointer updated, and the other which started off as a 'plain' PMC, has temporariky becomes a Dog by beeing assigned to from a Dog value, but will change again the next time we assign something to it?