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. On the other hand, my Dog $spot = Dog.new("waggly tail"); my $plain = 1; $plain = $dog; # is $plain temporarily or permanently a dog now? $plain = Cat.new(); # run-time error or is $plain now a cat? 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? Do we need a PMC flag saying that our type is fixed? And if so, how do we handle my Dog $dog; # dog has the 'undef' vtable pointer type # but is still a dog $dog = Dog.new(); # dog now has the 'dog' vtable type. 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???? I'm confused....