Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66251 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22619 invoked from network); 26 Feb 2013 17:14:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2013 17:14:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.219.52 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.219.52 mail-oa0-f52.google.com Received: from [209.85.219.52] ([209.85.219.52:48243] helo=mail-oa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/A5-16132-22CEC215 for ; Tue, 26 Feb 2013 12:08:50 -0500 Received: by mail-oa0-f52.google.com with SMTP id k14so5572164oag.39 for ; Tue, 26 Feb 2013 09:08:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=91pJHOgs9M6vvzrUsv5/BUH4RCowNzoe1aiZi2b3ZDU=; b=Y+AHeBYIDKbmW3Q0Bfsojas1fiv8iYGbqLR5BwL9s48oy/USNFM0Jsmx8s/szlBEsN vNqa89aWHJ3SecZS+zTwLD0bWLnU+JI6f61W2zLmiCqWV8x1oaVwwUADsUJ/sap8ieh8 e3ERhXTCB3gmc92fiMi3P8k8k4sQ9wdmaLaBykRIMHFCh7LDmRaV9UaAY96eOfSBvyn4 WzjqkSLkuvo8uUlhceULDHzGa2yI6xaFEHbzugeRkzYFlRxyOUigH/uIBaHTqhFvbVwf hy8YcJCLdrBD2JH2qB4t9nW82TTQgRRpD8XxzAPECVy7RHxGscfXqn9ELA63zoKAL7EL f+5w== MIME-Version: 1.0 X-Received: by 10.60.20.35 with SMTP id k3mr2099231oee.119.1361898527428; Tue, 26 Feb 2013 09:08:47 -0800 (PST) Received: by 10.182.237.75 with HTTP; Tue, 26 Feb 2013 09:08:47 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Feb 2013 20:08:47 +0300 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=e89a8fb206f2f29df804d6a3b5d2 X-Gm-Message-State: ALoCoQkuMy3WuMIxN1KryMh25AOHcZ+GzmzOvo0CeHBn3m1PDKhgZEMT/C6BuEgh5zCl/gnVUOybpczC4pC11uU6cFzdLL2UMdf+diE79sSuMHrAkCGOBtAjnN5DkhokKps9evceuU1o Subject: Re: [PHP-DEV] Allow (...)->foo() expressions not only for `new` From: dmitry@zend.com (Dmitry Stogov) --e89a8fb206f2f29df804d6a3b5d2 Content-Type: text/plain; charset=UTF-8 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). However it doesn't handle BP_VAR_FUNC_ARG, where decision about read/write context must be done at run-time. > 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. > > no sense, but it may call __set() magic method, that may print something, clobber something, throw exception, etc... > 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? > > Actually, I think IS_TMP operands shouldn't make any problems, but I can't be completely sure. Thanks. Dmitry. --e89a8fb206f2f29df804d6a3b5d2--