----- Original Message -----
From: "Perl6 RFC Librarian" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, August 29, 2000 10:19 PM
Subject: RFC 171 (v1) my Dog $spot should call a constructor implicitly
> my Dog $spot should call a constructor implicitly
>
>
> The current optimization syntax my Dog $spot should be extended to call
> some implicit constructor and create a Dog object out of the $spot
variable.
>
>
> =head1 DESCRIPTION
>
> The current syntax is largely for optimization, forcing the programmer to
> repeat herself when initializing an object:
>
> my Dog $spot = Dog->new();
>
> That call, in itself, is not overly onerous. Consider:
>
> my Animal::Mammal::Dog $spot = Animal::Mammal::Dog->new();
>
>
> Provided this RFC is adopted, this call can be changed to:
>
> my Dog $spot = "Spot";
>
Hmm, I see problems with this. First, let me say that I feel your pain. I
am tempted to make all subclasses colon seperated names. And I've developed
several libraries that have up to 8 or 9 classes deep. There is some beauty
in:
import pkg1.pkg2.pkg3;
pkg4 x = new pkg4();
Actually, out of convention for larger apps, we always fully qualify our
function / class names. So I should probably make an RFC for the perl equiv
of pythons:
from pkg1.pkg2.pkg3 import pkg4
It should easily become:
use pkg1::pkg2::pkg3 'pkg4';
my pkg4 $x = new pkg4();
But back to the problem at hand.
First greatly stylistic compatibilty. An inexperienced programmer would
see:
my Dog $spot = "Spot";
And become confused. It's totally unintuitive (at least so far as other
mainstream OO languages go). It looks like Dog could be a type of String
subclass.
The next most important point is that, up until this point, there has been
no enforcement of the constructor name (nor for the $self name). This
obviously requires it. Now there have been numerous discussions about RFCs
that required such standardization. Some stronger than others. I don't
think that this alone is a strong enough case to break backward
compatibility (with things like DBI->connect).
As with the above, the problem you are trying to solve is long type-names
(which is a bazzar thing to find in perl anyway). I just think that there
are better ways of skinning that cat.
-Michael