Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94658 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38954 invoked from network); 23 Jul 2016 20:46:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2016 20:46:23 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.223.170 mail-io0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:33434] helo=mail-io0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/85-05797-E97D3975 for ; Sat, 23 Jul 2016 16:46:22 -0400 Received: by mail-io0-f170.google.com with SMTP id 38so132655846iol.0 for ; Sat, 23 Jul 2016 13:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/TAA90W7QTtLNj45veKO0kS2quaTm4jOO4mtO0J0rbA=; b=muzHroLYCtJQWiOj9u2q/t8qXUmnz0qub97XFHHhL5eE1LRZ+sHZqwDib6zgKIJxkj UTm+M2tvzYYPnou14RZ4ss0fkoN0C+EYbzEP9bcO8hL5CFUE1QNTsf3n+TCrDQe3Rp5l xrzljMkLzWSpPbmEt32XOSnK15MSm4WuISLHgUhH2fidLO+fVe62nK1BMh7vCzos0fJT nbQBlA4VlXAixeJklA5ajhK1ibK/teBwgMt28Sy1vgBvs9U8lQCgaSYhVwkuQYa0kt/s RlmflZrRHUzEjHUJB2MLDDBZnUFodWk9NVFhbDjsFYOh81RRXDMOhXTkYkbGdAVGs6BB +Qsg== 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=/TAA90W7QTtLNj45veKO0kS2quaTm4jOO4mtO0J0rbA=; b=ejD2ZkaszbDTI0oVMYtjULftmgI+FrGgljAG7dcVfYMT6JmLiLQgeH8fwkRIn1YYYC knGSGe1HXmkZwM4mc50jxdUqREz+vfnAsnpSoLV9+l644K4u5WkMbBJdA/+wa3CFlCok H/Z6mKJNz6OvnLbbAKbkH2BvDkAWZJlrKSRhLRkEW7/nkZF9395gG+Ho0rhL44iFs0n6 Zn+6NpVlpspQe0/GD11g8f1PPbFQclvthHQg7vl4eNg5L9jqQxshu6aTrnxeHhsXJlLS UTkNd5J1Yrowzty8sPAsLvZ7pTtB1QBZFZA1OJO0VuFUkwNP2JapD/6avikWwHaa546W jDUw== X-Gm-Message-State: AEkoouuNryXDvNm0qiSdm64vmESgBG6E0V3Kj/79uoE5UwdAWvgE4fK7/Twv+BUpA8rDeSCaKKrPXwJaRVFXgA== X-Received: by 10.107.4.198 with SMTP id 189mr13807726ioe.143.1469306778967; Sat, 23 Jul 2016 13:46:18 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.36.117.201 with HTTP; Sat, 23 Jul 2016 13:46:18 -0700 (PDT) X-Originating-IP: [107.198.91.68] In-Reply-To: References: <5786dd74-8a32-eb16-aec1-77b12d5af1c1@garfieldtech.com> <1469202871.3732759.673953873.7108115D@webmail.messagingengine.com> Date: Sat, 23 Jul 2016 13:46:18 -0700 X-Google-Sender-Auth: 5cqTFue-vh0fjV4V3hRpfVehlqo Message-ID: To: Rasmus Schultz Cc: Larry Garfield , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Pipe Operator v2 From: pollita@php.net (Sara Golemon) On Sat, Jul 23, 2016 at 4:15 AM, Rasmus Schultz wrote: > FWIW, I've read the manual page for the Hack page, and the RFC, a couple of > times now, and I simply don't understand it. > Perhaps the documentation needs clarifying then. > Are most PHP developers going to understand this feature, the meaning of > $$, and when/how to use this? > Yes. PHP developers are excellent at Google and StackOverflow. > Are they going to be able to read code written in this way? > Yes. > To your knowledge, are there any other languages where this feature is > found, or is it another one of those exotic features currently found in > Hack and nowhere else? (I know a bunch of languages, and this feature > doesn't ring any bells.) > Elixir, F#, Swift (via library extension), ISTR a few others when I was researching a few months ago, but can't recall them offhand. > How does this feature compare with the cascade operator more commonly found > in other languages? > To turn your previous question around, what languages? I see them complementing one another, serving different goals and solving different problems. I suppose you could ask how this compares with short ternaries, coalesce, or bitwise xor, and the question will make as much sense. > 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. > I would rather consider them both since they solve different problems in different ways. > I know that Hack may be closer in nature to PHP than some other languages, > but if someone is familiar with both, likely they're not coming from Hack > and moving to PHP, they're likely moving from PHP to Hack, so language > similarity might not be the best argument for referencing Hack on this > point, as opposed to referencing other languages... > Fair point, I'll add mentioned of the above languages to the RFC. > 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. > It's also what makes the cascade operator unable to solve all the problems which the pipe operator is capable of solving. Cascade applies to a very narrow band of instance method calls. Pipe applies best to static methods and procedural functions (which some applicability to methods). The flexibility of being able to place that lhs element in an arbitrary location is what makes it powerful. > Rather than writing extremely long expressions, as demonstrated in the RFC, > I think, personally, if this feature were introduced, I'd lean more on > intermediary variables, with names, that clarify the meaning - referencing > a bunch of intermediaries with a nameless variable doesn't help readability > at all, in my opinion. > The RFC states why this may not be a preferred course. How do we know, at a glance, that these well named intermediates are/aren't used later in the scope? What happens to destructor ordering when the variable lives till the end of the function? How does this impact optimization potential? > In contrast, I have no issue reading expressions with the cascade operator; > again, maybe that's just because I'm familiar with that operator from other > languages, but I don't think the nameless $$ variable helps readability or > understanding. > You keep acting as if pipe vs cascade is even a competition. It's not. They're different solutions to different problems which require different approaches. -Sara