Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91724 invoked from network); 23 Jul 2016 11:15:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2016 11:15:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.213.46 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.46 mail-vk0-f46.google.com Received: from [209.85.213.46] ([209.85.213.46:33357] helo=mail-vk0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/4E-24343-7D153975 for ; Sat, 23 Jul 2016 07:15:36 -0400 Received: by mail-vk0-f46.google.com with SMTP id x130so189244419vkc.0 for ; Sat, 23 Jul 2016 04:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EYeN+IcghLejYwW3zBBxBtIc9+Fnsdvc4b80XAjr+UQ=; b=D3g3U3xvRg82fLVmspPdfZ7RrSzyzp+Mh0BzTnV6/q7zRaMDPey87O1ENNYegYCJtW 2pHAgOBVfPEKwv7K9/Ei6Rb2PE2SIkXzYBLmEJCT0+zzX2zfHSK8f5Qyku6k6LsZbGdP xMiyhu2srYeFMzXaXUFw0EdqnNQiFIiNvrHGNdAvkfFAyuc8/cJ8meVh54dxlYyLoRHL F8J5NGTp/l5BGEbFiHC1Ip2pQL5eCEgEDzXqcj8Aqi3r8vKdNCJT50md8+3WBoLn4yqS HrkW2mdebVo4RbSGJcOOxqycyXKvA2QV+8/9TbCIcVW/BXiclNTReAOtQjmnN0/3rSX5 flvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EYeN+IcghLejYwW3zBBxBtIc9+Fnsdvc4b80XAjr+UQ=; b=Hue2zfJLmhGgF0FmqeRcnwculTFaZaYEKt6YBnSZS9nctfSVmeUb9pyoAYUHB7CB+x lRkmnnZ2IdC/9ordEYQ8Aub11tNen67djZIYl0VBZC0tgiQDJwDdxp/t19+P6x0oUR7o B7G1leFT0TSUgvDsNuFUwE/ZJgeWVz3XPRUCoUKdgUAU71Enfv5Qh1AYtqQjqieuQNQr L4Avcq++N/vUIkewnUs3yAOjmEL4tRV+2fX4U7AAL0Dxgnhnvw7U5jl4tSUIJcDo+bWr Af9TnVJNdW5GY3r8tuuCly1cJUVYO1Nw7pkQjMLBtjLrNCSejJRpjEPg46/+JIuNr634 K3VQ== X-Gm-Message-State: AEkoouumPV7Yf4tHbc4k0qBI3Wv/ZolO9fYOqjWVHH+eFcmckhwcOb54jt1WONW60yUEXDkBMd457v5qyR7lIQ== X-Received: by 10.159.39.39 with SMTP id a36mr4189810uaa.86.1469272532485; Sat, 23 Jul 2016 04:15:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.153.195 with HTTP; Sat, 23 Jul 2016 04:15:31 -0700 (PDT) In-Reply-To: <1469202871.3732759.673953873.7108115D@webmail.messagingengine.com> References: <5786dd74-8a32-eb16-aec1-77b12d5af1c1@garfieldtech.com> <1469202871.3732759.673953873.7108115D@webmail.messagingengine.com> Date: Sat, 23 Jul 2016 13:15:31 +0200 Message-ID: To: Larry Garfield Cc: PHP internals Content-Type: multipart/alternative; boundary=94eb2c12324c60a2dd05384babb7 Subject: Re: [PHP-DEV] Pipe Operator v2 From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c12324c60a2dd05384babb7 Content-Type: text/plain; charset=UTF-8 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. Are most PHP developers going to understand this feature, the meaning of $$, and when/how to use this? Are they going to be able to read code written in this way? 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.) How does this feature compare with the cascade operator more commonly found in other languages? 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 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... 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. 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. 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. Just my two cents. On Fri, Jul 22, 2016 at 5:54 PM, Larry Garfield wrote: > On Wed, Jul 20, 2016, at 11:37 PM, Sara Golemon wrote: > > > > However, the introduction discusses fluent chained methods of objects, > and > > > states " This RFC aims to improve code readability by bringing fluent > > > expressions to functional and OOP libraries not originally designed > for the > > > task." The examples, however, all seem to be centered around > procedural > > > calls. (A static method call is the same thing as a procedural > function > > > call in this respect.) When dealing with methods on an object, it > seems it > > > wouldn't offer much. > > > > > In this context, I'd argue instance method calls aren't much different > > from static method calls either, but I wanted to avoid too many > > abstract/contrived examples. > > > > I suppose one might do something like: > > > > return $this->loadConfig() > > |> $arg->useConfig($$) > > |> $this->loadUser($$) > > |> array_merge($$, $this->userDefaults); > > > > But the PSR7 example is already contrived as it is. > > > > > This other recent discussion/proposal for a "Cascade" operator seems > like it > > > would handle the OOP/method case much better: > > > > > > http://news.php.net/php.internals/94466 > > > > > > Note: I am not suggesting one is a substitute for the other; rather, > that > > > they are complementary by addressing different parts of the problem > space, > > > and the Pipe RFC should likely not emphasize OOP usage potential as I > see > > > not a great deal there. I am still in favor of it, but let's not > over-state > > > its use cases. > > > > > Fair enough. They certainly complement one another and I wouldn't > > argue either is a one-job-fits-all solution. I wasn't trying to > > emphasize OOP usage so much as include it as applicable. I think we > > might actually be agreeing in principle even if we're diverging in our > > word choices. :) > > I agree. I'm entirely on board with the feature; more just critiquing > the RFC intro text, which mentions OOP fluency as a use case, which I > think is an over-reach. It's a useful enough feature even without > talking about that, and it seems we agree that the syntax when used with > methods is a bit awkward. > > > P.S. - I'm totes going to make that a secondary voting choice now. > > Name the token, 50% majority wins. > > :-) > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c12324c60a2dd05384babb7--