Re: RFC 171 (v2) my Dog $spot should call a constructor implicitly

[email protected] (Hildo Biersma)
Newsgroups perl.perl6.language.objects
Organization Morgan Stanley Dean Witter & Co.
Message-ID <[email protected]>
Bart Lateur wrote:
> 
> First: I don't like the idea of some user supplied code being called
> whenever you declare a new variable, *unless* the author of the class
> created a sub *especially written* for this purpose.

Exactly.  Even then, the arguments must match.

So, if Dog::new() takes one argument, and has also been declared to
be the 'implicit constructor', then:

  my Dog $spot;

is a syntax error.

  my Dog $spot = 'hungry';

is allowed.

 
> Suppose all you want is a variable that can reference existing Dog
> objects, I definitely do not want that a new object that I don't need is
> created, every time I get to the declaration.
> 
> Do you really want:
> 
>         for (1..1000) {
>             my Dog $spot;
>         }
> 
> to create 10000 unused Dog objects? Ugh! (not "Ug")

Agree.  I think the RFC confuses the notion of object with the notion of
reference.

 
> But I agree that anything beyond that is simply horrible. You'll only
> drive more people *away* from OO, because it generates so horribly
> inefficient code. If you want a constructor called, than FGS *call* a
> constructor. Maybe you can reduce the syntax necessary to do that, but
> please don't do it behind our backs.

Agree.  Either learn from C++ or don't go this route.

Hildo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.