Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66250 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16305 invoked from network); 26 Feb 2013 16:49:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2013 16:49:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.51 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.51 mail-oa0-f51.google.com Received: from [209.85.219.51] ([209.85.219.51:61339] helo=mail-oa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/F4-16132-887EC215 for ; Tue, 26 Feb 2013 11:49:13 -0500 Received: by mail-oa0-f51.google.com with SMTP id h2so5591137oag.38 for ; Tue, 26 Feb 2013 08:49:09 -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=MfpKtW7t+4imw+kvoWVp+yTJ+mmA/VTcEJKxc8rBkmI=; b=stQrQs68gpOFYaWIWL7ODRhhmNaV+2KAPww2U09TlQiWbl+O8li3NSS4eAkzsu+l9b ihluImbTT6W9lKiPsFWN+Q7MaGOIFN1rB3/Qf+FZv73ari9ZMR/FH+Vs7Eq8SLjOFwrM h6YouCu0oOKsMBtFpYRAgRqQNgOlftptuuHYGLlHZCO9xE4agsAXHwl077UY85z3VocX cZYAnT0a8EVgGjmtpdqQS69x1kXdbM9IfhRZ3disz56kQUP/p7Cr2pQOU5+0l2NWHqhb av+jEItugYceLlvDd0rE/V1S2P9VEnLYiVLbn6LTyCoYF/QWYGQcyMrSG6HE7R9Ej8+G ol2w== MIME-Version: 1.0 X-Received: by 10.182.161.39 with SMTP id xp7mr12202787obb.71.1361897349028; Tue, 26 Feb 2013 08:49:09 -0800 (PST) Received: by 10.182.49.136 with HTTP; Tue, 26 Feb 2013 08:49:08 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Feb 2013 17:49:08 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d04428768b5a4c204d6a36f85 Subject: Re: [PHP-DEV] Allow (...)->foo() expressions not only for `new` From: nikita.ppv@gmail.com (Nikita Popov) --f46d04428768b5a4c204d6a36f85 Content-Type: text/plain; charset=ISO-8859-1 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, but things like (new foo)->bar = 'x' will work. Though I'm not quite sure whether this is really necessary, at least I don't see much use for it. Reading your mail again, I missed the second point (about destruction of temporary). But I wonder how it could cause any issue. I mean, FREE op is only inserted when expression is used as statement, which is not the case here. Or am I missing something? Nikita --f46d04428768b5a4c204d6a36f85--