Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114777 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79381 invoked from network); 8 Jun 2021 01:25:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2021 01:25:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C77FA1804DA for ; Mon, 7 Jun 2021 18:39:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Jun 2021 18:39:53 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 2E09115CC for ; Mon, 7 Jun 2021 21:39:51 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Mon, 07 Jun 2021 21:39:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=t6TQ42 2P7mqQJ/WjtwslA5aRQJ3TAsFSXoGrHrSWcJQ=; b=Yl3XgCJ3/4+vhwiVd9sSej 98IJVKGXGvhaow1GBZIo/C1XofyUc4mP803iD8l6SG9F2Gpz73yfK1Kcz3nN41Xg ZcpfbVXtFMkF2S5qQTq46V51q2h5w9zd31vslGKBAKPniRO9TM5YAoiXIi6YVLDR g3YFzM9M3kD8M1JEu5VVCuqdXE7mPE5q/qQBO9Mx6TDY7jU3rwi57yWRnkLCDJTN mWRDsoiuv58Wh+uzIU84qxRT98ndUuIs6vsQ2Pyhgnst9l5vyyAMe2CpG2bkfqPH RpfEDmPjOKalmbw6WedHg3Y6LHXmHNNVh/Ug3lz9HyTs1vQYBgXLM48hqTJApy9Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtkedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeejkeehfeffvdehtdeltdegueeuhfehueehuedvgfef ffefgefgjedvheeugfduleenucffohhmrghinhepphhhphdrnhgvthdpfhhshhgrrhhpfh horhhfuhhnrghnughprhhofhhithdrtghomhenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 94B56AC0062; Mon, 7 Jun 2021 21:39:50 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-519-g27a961944e-fm-20210531.001-g27a96194 Mime-Version: 1.0 Message-ID: <9c271680-da84-4de1-9f28-c6507f4f557f@www.fastmail.com> In-Reply-To: <68DF0F38-621F-407F-ABEE-FEF388122EC9@newclarity.net> References: <68DF0F38-621F-407F-ABEE-FEF388122EC9@newclarity.net> Date: Mon, 07 Jun 2021 20:39:25 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Pipe Operator, take 2 From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jun 7, 2021, at 8:09 PM, Mike Schinkel wrote: > > > On Jun 7, 2021, at 3:00 PM, Larry Garfield wrote: > > > > Hi folks. Me again. > > > > A year ago, I posted an RFC for a pipe operator, |>, aka function concatenation. At the time, the main thrust of the feedback was "cool, like, but we need partial function application first so that the syntax for callables isn't so crappy." > > > > The PFA RFC is winding down now and is looking quite good, so it's time to revisit pipes. > > > > https://wiki.php.net/rfc/pipe-operator-v2 > > > > Nothing radical has changed in the proposal since last year. I have updated it against the latest master. I also updated the RFC to use more examples that assume PFA, as the result is legit much nicer. i also tested it locally with a combined partials-and-pipes branch to make sure they play nicely together, and they do. (Yay!) Assuming PFA passes I will include those tests in the pipes branch before this one goes to a vote. > > In general, much nicer with PFA than before. > > A few questions though, although #1 is probably best answered by Derick Rethans: > > 1. Will PHP consider a piped sequence a single expression? More > specifically, will XDEBUG consider it a single expression, or could > XDEBUG be able to set a breakpoint at each pipe assuming they are on > separate lines? > > I ask because if pipes were an indivisible expression from the > standpoint of XDEBUG and breakpoints I would not want to see them > included in PHP. Alternately if included in PHP I would avoid using > them like the plague just like I avoid using fluent interfaces because > of their inability to be breakpointed at each step in XDEBUG. $foo |> bar(?) |> baz(?); will produce the same AST as baz(bar($foo)); So whatever Xdebug can do with that AST, it should still be able to do. > 2. Besides `throw` will there be a way to short-circuit evaluation > mid-way through the pipes without having to write all of the callables > to respect said short-circuiting and just return? > > For example, could returning an instance of an object that implements a > `ShortCircuitPipeInterface` allow the pipe to short-circuit, or some > other way to short-circuit and then determine after the pipe if it was > short-circuited? What you're describing is effectively monads. (There's that scary word again.) That is not covered here, although I mention it in the future scope section. There's a couple of ways it could be implemented, although you can already do so today in user-space with a method instead of a dedicated operator. The caveat is monads essentially have to be either untyped or use generics, so for now we're stuck with untyped monads. Alternatively, you can wrap each callable in another function that wraps the short-circuiting behavior around it. That's essentially "railroad oriented programming", a term coined by Scott Wlaschin: https://fsharpforfunandprofit.com/rop/ In other words, "I want that, but it comes later, via something more robust." --Larry Garfield