Michael Fowler <[EMAIL PROTECTED]> writes:

> On Fri, Sep 01, 2000 at 05:23:27PM +0200, Slaven Rezic wrote:
> > Often, there is the case that "my" is used before actually assigning a
> > value to it. For example:
> > 
> >     my Foo $foo;
> >     if ($cond1) {
> >     $foo = new Foo 1, 2, 3;
> >     } else {
> >     $foo = new Foo 2, 4, 6;
> >     }
> > 
> > If we have implicit constructors, will this cause unnecessary
> > overhead, that is, calling the implicit constructor and then the real
> > one?
> 
> Yes, so don't do that.  If you want optimization, I've been suggesting my
> $spot : isa(Dog) (actually, I've been suggesting my $spot isa(Dog), which
> was a typo):


But that's *so* ugly for the (In my code at least) more common case.
If all you want this behaviour for is to save typing, what about
simply *extending* the current syntax so you'd one of:


    my new Dog $spot;    # Not sure the parser'd like that.
    my Dog $spot : from(new); # same as 'my Dog $spot = Dog->new

Actually, I kind of like the second one (though I'm not sure 'from' is
the right name) as it allows you to specify the appropriate
constructor. The advantage of this is that the existing syntax still
works so that those of us who are already using it in anticipation of
the glorious day when we finally get some optimization from it won't
have to rethink the way we do things. Okay, if you want the new
behaviour you have to learn the new syntax, but hey, that's why it's
new. 

-- 
Piers

Reply via email to