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.
- Re: RFC 171 (v2) my Dog $spot s... Nathan Wiger
- Re: RFC 171 (v2) my Dog $spot should call a cons... Nathan Wiger
- Re: RFC 171 (v2) my Dog $spot should call a ... Piers Cawley
- Re: RFC 171 (v2) my Dog $spot should cal... Nathan Wiger
- Re: RFC 171 (v2) my Dog $spot shoul... Piers Cawley
- Re: RFC 171 (v2) my Dog $spot should call a ... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot should cal... David E. Wheeler
- Re: RFC 171 (v2) my Dog $spot shoul... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot s... David E. Wheeler
- Re: RFC 171 (v2) my Dog $spot s... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot s... Bart Lateur
- Re: RFC 171 (v2) my Dog $spot s... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot s... Piers Cawley
- Re: RFC 171 (v2) my Dog $spot should call a cons... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot should call a ... Piers Cawley
- Re: RFC 171 (v2) my Dog $spot should cal... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot should call a constructor i... Slaven Rezic
- Re: RFC 171 (v2) my Dog $spot should call a construc... Michael Fowler
- Re: RFC 171 (v2) my Dog $spot should call a cons... Piers Cawley
- Re: RFC 171 (v2) my Dog $spot should call a constructor i... Michael Fowler