Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94467 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69271 invoked from network); 11 Jul 2016 15:29:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2016 15:29:54 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:35293] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/C8-22463-07BB3875 for ; Mon, 11 Jul 2016 11:29:52 -0400 Received: by mail-wm0-f44.google.com with SMTP id f65so68012108wmi.0 for ; Mon, 11 Jul 2016 08:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=UgoQbF3bP7lm/NrsO7f6oDDo4Yt/AeIAnrJCgmDn4aY=; b=M3Rhi2O3W2bHUlexeJjCEnMEmMwWf9ohrrmXmpiaZUdZM/qt62cnLh3OGr7w/ID10e ijTdfK2+Dj1eCM22qtjQB3XJhfROY1Wknpsig5nOixW2XOysVjulQadHij35QjQLVrAN 9/NRDXFmaRhDHW+8MxxZG1lqq74koARaSeHRpKY9KHlKJR5D0e0d1KhaNKPMhPTBoI+a pv2ZtCm/VBJw9Hq2Ol5N61/D1NvkBN2OXGa0XU21pCT91j59UlmC2kTpT890yhBWlrCj 4uqXMK26LX4odSnwU69ePLEvrgEhHh2yAslcZ/Ww3fnP69sKqgQLZxLvo1vKKyac4BBV vBxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=UgoQbF3bP7lm/NrsO7f6oDDo4Yt/AeIAnrJCgmDn4aY=; b=mkkz0AjqBP8gNpZK7EMNTHYl/jsf0QUT3e0bes/fqlMlZZ7XSNcZxsPFhmNFSOVUHl +QvMorkSaaLlnjOihmHwKAbk6Us6l06FDkdrZ0FevqiLJl2pTRBmO2iOgZkEDdrepGMC llVHMVV2mF2690K7sPVOrG89MatHcjekSQiC3F9VefXYRd6Rbrqan2CRA3U0sS8gd+mc 6yLF9DulrXCzCMH6SOQRAY4G7sH6jDh6hLCOf6leJOFTCIDHdRhMNo2+QpXXqGSwV0YH wLhUu4VCitFs/kH/dsTxS2WDDmujjy9Abi4uWSW4gEDKmIlw4YLEUKgA7XZXKMhfPeqP ATKA== X-Gm-Message-State: ALyK8tJgtzeXfqYaK7u1gErMQLrm9ABbtHVKvjIBbFYdqSzNVNzOxIfemxU6REfGU9pIAA== X-Received: by 10.28.52.142 with SMTP id b136mr19495278wma.35.1468250989065; Mon, 11 Jul 2016 08:29:49 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id zd6sm365993wjb.23.2016.07.11.08.29.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 08:29:48 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <86455a1e-eb57-1f30-9016-ac70c9f30bdd@gmail.com> Date: Mon, 11 Jul 2016 16:28:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Cascade Operator (was Re: [PHP-DEV] Proposal for php7 class method return) From: rowan.collins@gmail.com (Rowan Collins) On 11/07/2016 16:15, Michael Morris wrote: > But for that to currently work setSomething must return $this. A cascade > operator would avoid this. What about => ? > > $a->setSomething('here')=>setSomethingElse('there'); This will be ambiguous with array syntax, e.g. $foo = [ $a->foo() => bar() ] could be a call to $a->foo() for the key and to bar() for the value, or just a chain ending with the array value $a->bar(). Naming things is hard. Inventing operators is harder. ;) Also note that it's the *first* call that needs a special operator, in order to discard the normal return and substitute the left-hand side, otherwise mixed chains become ambiguous and probably horrible to implement in the engine: $foo->bar()->baz()=>bob() // what is $this inside bob() ? > For this sort of chaining I'd propose, in addition to the cascade operator, > the chain operator. This would work like the cascade operator except that > the return of the function is implicitly the first parameter of the next > argument in the chain. Something like this? > > $a->add(1, 2):>subtract(3):>add(4); // return 4. This exact feature was proposed a couple of months ago by Sara Golemon. See https://wiki.php.net/rfc/pipe-operator and the accompanying discussion http://marc.info/?t=146196088900001&r=4&w=2 As far as I know, it's not been formally withdrawn, so might be resurrected in some for for 7.2. It might be interesting to see a cascade operator at the same time, but some of the same concerns that came up in that discussion will probably apply to any proposal. Regards, -- Rowan Collins [IMSoP]