Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94644 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2745 invoked from network); 23 Jul 2016 14:40:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2016 14:40:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:35569] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/7F-24343-3D183975 for ; Sat, 23 Jul 2016 10:40:21 -0400 Received: by mail-wm0-f49.google.com with SMTP id f65so87294878wmi.0 for ; Sat, 23 Jul 2016 07:40:19 -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=4WazESnSp/aKBA/Ge8gx6ktI/a2pgGQA5vZ46La2jBA=; b=fqggG9ZWmX4rdmIUbbhX7Hf9/DOWTX5QW4M2b0d7JMw4uRoKaqkXTwjgAsICg8o9LD ElKt/PPQ43pWQd7huC3ZPrJiwsv5lIPiwsI3+PjOT2dPrpom+CaPkXcB65T2eukAGSmj RNdHhGZ/P2uoSaq9CIGZdVw0Nn/Uwk9Zd9pTf2aPBYTpQ2r2u/R5ZHerzENdmUTXB3kd JY7/ukKMBayKcFOVYqjEz5KR5vinCCpMdYUDrksNzKBybQdzIWJjTZMz+TTI7wO9vLTL hXhuXUpaKOqOFdeHDJ0IN7RyMtYFO41u9p19YSmdf/vEfmJqlPXDQiKLa7ZO9PvspRLD gsPQ== 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=4WazESnSp/aKBA/Ge8gx6ktI/a2pgGQA5vZ46La2jBA=; b=dHjP6mzGneXgqQxfIjdnywvDr1fA15Z1Slv5auKpp9H02rjpVE9E3UK9RzeFx0q08/ YRJzVdTBRWVsfd3y0whIpsytYG87HqXO6doc4gd5BEbnJCusOSNJpiw43TN0cUEf4LCd dW6Qens+8FxIEtBIh9W9B5MSG9jjNPPQrrNcvnPMTj4zGIWXxNE98M8mL4tBeG7d7vTO zIgnMSAHzVJhbe7tck4BJnFwlECigyLlUl/uukYsIxtFusMFHQm4HREDTciTG0Kra2hG B3aG640wCOqSZ0/FIyASnhGw5oBLmJMpE53LPJkrkOWSJW9A4jOcLxvBjmVQgNA8UicD tUww== X-Gm-Message-State: AEkooutHdNuyYflq8UjlGm4Hf18mkcHvc9bfsbTiag76bsm+6xYU62Agd1oo3FciGyPPwA== X-Received: by 10.194.145.194 with SMTP id sw2mr6705037wjb.16.1469284815717; Sat, 23 Jul 2016 07:40:15 -0700 (PDT) Received: from [192.168.1.5] ([95.148.161.240]) by smtp.googlemail.com with ESMTPSA id pm1sm6193341wjb.40.2016.07.23.07.40.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Jul 2016 07:40:15 -0700 (PDT) To: internals@lists.php.net References: <5786dd74-8a32-eb16-aec1-77b12d5af1c1@garfieldtech.com> <1469202871.3732759.673953873.7108115D@webmail.messagingengine.com> Message-ID: Date: Sat, 23 Jul 2016 15:40:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pipe Operator v2 From: rowan.collins@gmail.com (Rowan Collins) On 23/07/2016 12:15, Rasmus Schultz wrote: > I mean, maybe it's just me, because I'm familiar with the cascade operator > from other languages - but it seems simpler, more intuitive, easier to pick > up, and appears to solve most of the same problems? If so, perhaps it would > be right to consider the cascade operator as an alternative to this feature. They're not really the same thing at all; in some ways they're actually opposites. The cascade operator is a way of discarding the result of an object-oriented expression, and reusing the same context repeatedly. The pipe operator is a way of capturing the result of a procedural expression, and passing it forward to the next expression. > It seems to me, the main difference between the pipe operator and a cascade > operator, is the anonymous context variable $$ created by the pipe operator > - I think, partially, this is what makes those expression hard to read; the > context changes (or does it?) along the way, but the (nameless) symbol used > to reference those objects, in the same expression, are identical. Yes, the $$ means "result of last expression". In essence, it's a bit like Perl's $_ variable, except that it doesn't exist outside the pipe syntax. It has to exist to say where you're going to use that result in the next expression. In the cascade operator, you don't need a notation for it, because the context is always on the left of the operator: $foo ->>setBar(1) // context is $foo->... ->>setBar(2); // context is still $foo->... But again, this isn't the primary difference between the operators; the difference is that one is a way of discarding results, the other is a way of carrying results forward. Regards, -- Rowan Collins [IMSoP]