Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37140 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82257 invoked from network); 18 Apr 2008 18:49:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2008 18:49:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 208.70.128.77 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 208.70.128.77 smtp-gw51.mailanyone.net Received: from [208.70.128.77] ([208.70.128.77:48286] helo=smtp-gw51.mailanyone.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/5E-10014-A3DE8084 for ; Fri, 18 Apr 2008 14:49:31 -0400 Received: from mailanyone.net by smtp-gw51.mailanyone.net with esmtpsa (TLSv1:RC4-MD5:128) (MailAnyone extSMTP sam@sambarrow.com) id 1JmveK-0002Bs-FF; Fri, 18 Apr 2008 13:49:28 -0500 To: Stanislav Malyshev Cc: internals@lists.php.net In-Reply-To: <4808EB94.3060509@zend.com> References: <1208535802.22418.1.camel@sbarrow-desktop> <4808EB94.3060509@zend.com> Content-Type: text/plain Date: Fri, 18 Apr 2008 14:46:58 -0400 Message-ID: <1208544418.27112.4.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Object instantiation From: sam@sambarrow.com (Sam Barrow) 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?