At 11:46 AM +0000 2/14/02, Dave Mitchell wrote:
>Dan Sugalski <[EMAIL PROTECTED]> wrote:
>>  Right, for typed variables. Most variables (i.e. anything you
>>  declared with a plain "my $foo" or "our @bar") are untyped and can
>>  change their types as needed.
>>
>>  If you did:
>>
>>      my $foo;
>>      $foo = Dog.new();
>>      $foo = FireHydrant.new();
>>
>>
>>  $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.

There's a flag in the flags field to mark the PMC as a permanent type 
or not. It's insufficient for "Type X or child of X" things, though.

>Or to put it another way, is the type of a PMC determined purely by
>it's current vtable pointer, and if so, under what circumstances
>are we allowed to change the pointer?

The variable's vtable functions are the only things allowed to change 
that pointer. The circumstances under which they change it are up to 
the authors of the vtables. For standard types we need to hash some 
things out for it.

>And can we indeed conflate the concepts of type as defined by a vtable
>pointer, and Perl-level type? Will there always be a seaprate vtable
>for each Perl-level type????

There will be at least one vtable per perl-level type, yes. Each 
package and class gets at least one, as do any lower-level 
user-defined types.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                       teddy bears get drunk

Reply via email to