On Fri, 1 Sep 2000 11:59:15 -0800, Michael Fowler wrote:

>>   my Dog $spot;
>>   if ($input eq 'Collie') {
>>       $spot = Collie->new;
>>   } elsif ($input eq 'Dalmation') {
>>       $spot = Dalmation->new;
>>   }
>> 
>> Becuase we're creating two objects when we really only want one.
>
>Yes.  That my Dog $spot should be either my $spot or my $spot : isa(Foo)
>(which I just recently made up) in this case.

But now you're throwing away the kid with the bathwater.

        my Dog $spot;

initially was syntax invented so that $spot was marked as only been ably
to reference a Dog, with as a result that code internally could be
optimized, by doing things at compile time why otherwise would need to
be dealt with at runtime. (use fields, as the most notable example).
Don't throw that away.

Your proposed isa(Dog) syntax is supposed to replace that syntax, while
the old syntax would get new functionality. It doesn't look nice, for a
start. The idea breaks the "if it does something else, give it a new
name" rule. How about:

        my new Dog $spot;

which creates a new instance of Dog, while

        my Dog s$pot;

doesn't.

-- 
        Bart.

Reply via email to