Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66240 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87050 invoked from network); 26 Feb 2013 12:29:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2013 12:29:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.41 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.219.41 mail-oa0-f41.google.com Received: from [209.85.219.41] ([209.85.219.41:60668] helo=mail-oa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/C0-16132-ABAAC215 for ; Tue, 26 Feb 2013 07:29:47 -0500 Received: by mail-oa0-f41.google.com with SMTP id i10so5011087oag.14 for ; Tue, 26 Feb 2013 04:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=PzwHQotY7ciHdBJ+yZs6ANstbg27PHFdTf5AIkuLm8A=; b=Mat2H9p/2bH5EMVB7Kmr0n8C5+NEuLvtxOrPM5AAReouXawrMRqpFUSctXhCLggB4a 4+6EByT28MWSP1OgORrNvJhfXpCb5KaxkKhLx2kPrIjV1rMy8bvyqHZKhvleoBC+utEj NlreyW2YZxr/hyHhVREh6lvxfxyMRNrQCuLn5DTNK0pQuqH6/YtX9g1Bx4c5q0zVWrCd KYJux3/SdNYoJ7VNl6Y5QE5Z5WYnhO0Yo3AHeJNOZyIeWG7rUlXUH928e460/JM25YfJ fkEHnMh6Lo9e8IoJTQ/dYW3wh021KFJtd+fndWzRglLrFm8CtCDMQaKTEIjrQHjvL/n3 1rPg== X-Received: by 10.60.24.197 with SMTP id w5mr1186792oef.6.1361881784139; Tue, 26 Feb 2013 04:29:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.76.167.202 with HTTP; Tue, 26 Feb 2013 04:29:24 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Feb 2013 13:29:24 +0100 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=e89a8ff1c30ef848aa04d69fcf8e Subject: Re: [PHP-DEV] Allow (...)->foo() expressions not only for `new` From: linepogl@gmail.com (Lazare Inepologlou) --e89a8ff1c30ef848aa04d69fcf8e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Nikita, 2013/2/25 Nikita Popov > Hi internals! > > PHP 5.4 added support for expressions of the kind (new Foo)->bar(), (new > Foo)->bar and (new Foo)['bar']. > > I guess it must have been discussed, but Is there any technical reason or conflict that prevents us from having something like new Foo->bar(), without the extra parenthesis? > I'd like to extend this support to any expression instead of just new. > > Why should be do this? Because it's just an arbitrary restriction. Removi= ng > it would for example allow clone calls in the parens, so you could do > something like (clone $date)->modify('...'). Which - you may have already > noticed this - is more or less a replacement for the DateTimeImmutable > class that was added for 5.5 (with the nice benefit of being fully > compatible and not being an object oriented abomination :) That's just on= e > example, but I think there are a lot more (especially if you also conside= r > that it allows array dereferencing too). One further use that is of > interest to me personally is for https://github.com/nikic/scalar_objects, > so I can do calls like ("foo")->bar(). > > A nice side benefit from this is that it removes a shift/reduce conflict > from the parser. > > The patch for the change can be found here: > https://github.com/php/php-src/pull/291/files. It's a very simple patch, > it > basically just changes one parser rule and adjusts the allowed opp types > for some opcodes. The rest is just the vm regeneration for the new op > types. > > I hope that this change is trivial enough to not require dragging it > through the whole RFC process. If there are no objections I'd commit it > sometime soon. > > Thoughts? > Nikita > Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel --e89a8ff1c30ef848aa04d69fcf8e--