Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66447 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96328 invoked from network); 3 Mar 2013 12:26:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2013 12:26:21 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.47 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.47 mail-oa0-f47.google.com Received: from [209.85.219.47] ([209.85.219.47:38417] helo=mail-oa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/E1-20272-B6143315 for ; Sun, 03 Mar 2013 07:26:20 -0500 Received: by mail-oa0-f47.google.com with SMTP id o17so8009243oag.34 for ; Sun, 03 Mar 2013 04:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=hWIhDF0ne4SanDi3c693brPoK+2ndh8AtyDv/+w0wlQ=; b=ZJi0v+TJdZkUayMdhQ+msVK+H325s/WWtTMDq6Tc68yngcw0GAm2BuwjSCXqYIMuWD Zsm9yAXwOq7NxgLM8ZdsXhOpJuehNcCTe9MWkgJ3Ms/b/WQupLOp65sYP38QVc75B4Bw iM3jxrp/IcoKTrSGtpPgRsWMuJDwg90tkT5331jdjaojd6j0y7aVsWe6ZDl7AKIFcAEY /nKsul8az3oNekzIZfkRxbxroYL1Ug2LxH9tJtqNn7gv7VI04u5dNeRGifmKd/R1VABK WyUT/jfwa99peZnQmA+YTj4UrmLm+65a/Zsf1tlRl/hDU9qvbS64rHgzximkasFkDPr2 1fOQ== MIME-Version: 1.0 X-Received: by 10.60.11.228 with SMTP id t4mr2651285oeb.42.1362313576410; Sun, 03 Mar 2013 04:26:16 -0800 (PST) Received: by 10.182.49.136 with HTTP; Sun, 3 Mar 2013 04:26:16 -0800 (PST) In-Reply-To: References: Date: Sun, 3 Mar 2013 13:26:16 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary=e89a8fb1ed06cb73d204d70458dd Subject: Re: [PHP-DEV] Allow (...)->foo() expressions not only for `new` From: nikita.ppv@gmail.com (Nikita Popov) --e89a8fb1ed06cb73d204d70458dd Content-Type: text/plain; charset=ISO-8859-1 On Tue, Feb 26, 2013 at 6:08 PM, Dmitry Stogov wrote: > On Tue, Feb 26, 2013 at 8:49 PM, Nikita Popov wrote: > >> On Tue, Feb 26, 2013 at 7:41 AM, Dmitry Stogov wrote: >> >>> Hi Nikita, >>> >>> I like the idea. >>> But note, that it may cause some unexpected behaviour and bugs. >>> I didn't test the patch I just guess it on my previous experience >>> introducing similar features. >>> >>> - usage expression in write context (e.g. passing constant by reference) >>> >>> function foo(&$foo) {} >>> foo("abc"[0]); >>> >>> - destruction of temporary result >>> >>> ($a . $b)[4]; // if ($a.$b) is destroyed? >>> >>> - in some cases destruction of temporary result may cause destruction of >>> final result >>> >>> ((object)(array("a"=>"b")))->a = "c"; // temporary object may be >>> destroyed before assignment >>> >>> All these edge cases must be carefully analyzed. >>> I like the current patch, and in case the edge cases won't require many >>> hacks, I'm all for it. >>> >>> Thanks. Dmitry. >>> >> >> I just played a bit with it and came up with the following (additional) >> patch to support use in write context: >> https://github.com/nikic/php-src/commit/31705dd8c53efe3bb52d6aae483a324e5a511ae9It throws an error if the write is done on a TMP or CONST, >> > > I like this patch more (it doesn't complicate executor). > This patch is on top of the other one, so the executor changes still apply. This one is only about write-context, but the executor optype changes were necessary for read-context (as in read-context CONST/TMP are valid, unlike in write context). However it doesn't handle BP_VAR_FUNC_ARG, where decision about read/write > context must be done at run-time. > Good catch, I didn't consider that one (didn't even know it exists ^^). This would require a few more changes: https://github.com/nikic/php-src/commit/6f5483f006794dc78f8c341b1a6d7ad18c2e56be Nikita --e89a8fb1ed06cb73d204d70458dd--