Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94482 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11655 invoked from network); 11 Jul 2016 23:14:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2016 23:14:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-io0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:34215] helo=mail-io0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/74-17655-F6824875 for ; Mon, 11 Jul 2016 19:14:55 -0400 Received: by mail-io0-f170.google.com with SMTP id q83so1727842iod.1 for ; Mon, 11 Jul 2016 16:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=fkvsaNT2jv301/6Cn+pwvHzLr589+NKmpWl45h1uQCU=; b=dxWzHwdHYKDBRxBPLrF/BUgHwoDzWohxbD/D8Yf4qLfTEkmbZ3YO3aywddH4KwSQ42 D2hzpVcJnAPWbCRmU925dWzUZHtyfuAiy3kakSA8q9nSQpmIkwyCzcpNavyYW00QrlaN aASGMT25bf5AQtakOvfcgVJVOJy5cOWJFxaO0pN8xdDKxZR68SEKUfSmm4anupD59bTE YjImh59kmvtGRgYsdXb6vNAbbBEdeBklAvjaryk23DA/nC458bmXae8Um6zohuJ43np9 sBIw1pbXms+JVq1Y6cW/IkbRQO785/VvgGZrhlW083LtM3ddD0PgT/b/O6ZECWrkAdJq bhGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=fkvsaNT2jv301/6Cn+pwvHzLr589+NKmpWl45h1uQCU=; b=dQXinw+1ngEC3Y0Pvdb0ZaQ5tz/vCrnRgJ/gSkUczM13UEPSNY4vfpj+tevKIRGpyq xyvJ37E9Xgs3LK56J4CrooXnvPb8aUHYbwd9RKY7fHQQSCYIVHDFpfYkksOpBob3YQDE kGx4J/2Obbjx5+wpT4FVAT/wJUALyQNSSwjUjsad7PxxOaUaJgakLKAnGPsVa5/Ks7kd 56m1WcaIEhSHaNzmPJ2Wc7hkdPiXdxlcyHbxoWyjAFa10fss4mspp6ZUoLxxwc9XTMcd kuPKTOe8vJ6X45pQzTchCBt/MSPJIfy5LQ3cjn1DjR3TlSnCI0Ro1hmMHzwU8PFI5OFV na8A== X-Gm-Message-State: ALyK8tKcWnZ6CS1KlcsC3nbw0xK3M6BNFHmWwvntx+CsUC6ED5phhxEvJNZv1Yqt1NG8VD4gDW05WcgoRSNNcQ== X-Received: by 10.107.172.70 with SMTP id v67mr19672715ioe.31.1468278893299; Mon, 11 Jul 2016 16:14:53 -0700 (PDT) MIME-Version: 1.0 Sender: jesseschalken@gmail.com Received: by 10.79.72.7 with HTTP; Mon, 11 Jul 2016 16:14:52 -0700 (PDT) In-Reply-To: References: <86455a1e-eb57-1f30-9016-ac70c9f30bdd@gmail.com> Date: Tue, 12 Jul 2016 09:14:52 +1000 X-Google-Sender-Auth: bAfI9tvn5qmxP0SvJRyXhehmmWI Message-ID: To: Rasmus Schultz Cc: Marco Pivetta , Rowan Collins , PHP Internals List Content-Type: multipart/alternative; boundary=94eb2c05ab28dde98905376451a0 Subject: Re: [PHP-DEV] Cascade Operator (was Re: [PHP-DEV] Proposal for php7 class method return) From: me@jesseschalken.com (Jesse Schalken) --94eb2c05ab28dde98905376451a0 Content-Type: text/plain; charset=UTF-8 On Tue, Jul 12, 2016 at 2:30 AM, Rasmus Schultz wrote: > > Would something like ->> be ambiguous as well? That's fairly close too > - a double-headed arrow, not unlike the double dots of other > languages... > > A few weeks ago I proposed a syntax for setting multiple object properties in an expression with the result as the object ( http://news.php.net/php.internals/93662). Both that feature and the cascade operator can be considered instances of a broader need to manipulate an object as an expression with the result being the object itself, and either feature could support both calling a method and setting a property: $this->setBlah( Blah::create(4) ->>foo = $foo ->>baz = ((new Baz()) ->>markFixed() ->>label = "Hello" ) ->>setBot(9) ); $this->setBlah( Blah::create(4) { foo = $foo, baz = new Baz() { markFixed(), label = "Hello", }, setBot(9), } ); Would it be incohesive to have two different syntaxes for setting properties and calling methods, like below? $this->setBlah( Blah::create(4) { foo = $foo, baz = (new Baz()) ->>markFixed() { label = "Hello" }, } ->>setBot(9) ); If so, some consideration should be made as to which syntax is preferred to solve this problem generally for both setting properties and calling methods. I prefer the "obj { .. }" syntax because it mirrors object literals in JSON/JavaScript, object initializers in C# and C/C++ and Haskell record syntax, is particularly concise when nested to create large trees of objects, and avoids the noise of "->>" on each line. --94eb2c05ab28dde98905376451a0--