On Mon, Sep 04, 2000 at 10:25:37AM +0100, Piers Cawley wrote:
> Maybe a compromise along the lines of:
> 
>    my Dog $spot = LIST; # $spot = Dog->new(LIST)
>    my Dog $patches;     # $patches is undefined but we assert that
>                         # it'll be a Dog. (Whether you can do
>                         # $patches->new is left as an exercise)
>
> Where the first element of LIST is not a Dog. If you want to
> autocreate a null object then you can do C<my Dog $spot = ()>

I was trying to keep away from the $scalar = (LIST) construct calling a
constructor with a list of arguments.  It's very unintiutive for me.

As for the latter, having on create an object and the other not seems
inconsistent.  It also precludes simple usage, as mentioned in the examples
section:

    my int ($x, $y, $z);
    my array_ref @matrix;
    my int %counters;


 
> That's not polymorphism, that's inheritance.

Ahh, of course, duh.

Well, I don't know how you think this proposal breaks polymorphism, and at
this point I don't particularly care.  Given several different objects, if
they all have the same method, calling the method on each will work just
fine.  I'm proposing an implicit constructor, not the breaking of OO.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to