Re: Object instantiation
| From: | Sam Barrow | Date: | Fri, 18 Apr 2008 18:46:58 +0000 |
| Subject: | Re: Object instantiation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37140@lists.php.net to get a copy of this message | ||
On Fri, 2008-04-18 at 11:42 -0700, Stanislav Malyshev wrote:
> Hi!
>
> > $result = new myObject -> myMethod();
> >
> > Is there a technical reason as to why this can't be done? If not can
> > this be changed?
>
> I think this can not be parsed unambiguously. This could be new
> (expression with ->) or (new expression)->expression. E.g., what this means:
>
> $a = new $foo->bar();
>
> is it a new object whose name given by $foo and then bar() called on it,
> or is it a new object whose name given by variable $foo->bar with empty
> ctor?
Yeah, that makes sense.
> Also, I'm not sure it's a good style - if you are creating object just
> to drop it immediately in the same expression, maybe it should be static
> method that creates the object internally?