Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126320 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id B08A71A00BC for ; Fri, 7 Feb 2025 07:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738913661; bh=TOsIwADYq9A7G7qhchxqezEI5Cag2bavylsnz5yUuWo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=H8QkflMOMsanf2ub+fB6Ysl542YzLSK3SHVOEDP6x2u/3xp5cYvtNRuoHBeBcNLu3 md3M9bU/koWaorwyoZH6642cgIAw5Kb1qqJ3pbT4YeqhySvmK2Yc00EmtAqBqkah8p BuJ+JkURd3MiWuUozocBLQQlM67EbuUATcH5Aragq8FpoT6ze+Daeh7rDiKleZUX5y 8UBZlDNHlYeljaKz0eKOIrJ4LULV1RXj40/40+q4pimY4MKJlCUQuIURmr8ETjEK0d boYZ+YFQVyBmwBtIsHXe4Zcu0oew+Xwp8JD3ogae6CPtc6L7KT/SYmEEJy58DKqPR3 PgfAGu2FaBvCg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C81BF1805DA for ; Fri, 7 Feb 2025 07:34:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Feb 2025 07:34:17 +0000 (UTC) Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e5b16621c28so1405252276.2 for ; Thu, 06 Feb 2025 23:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738913822; x=1739518622; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Y44bcrR3vjCvzlbnHWa0ro+3g7qoj/70tOjcRDEEyiM=; b=fpGcYVEjOoRAsGUAToqTunIfcSFHfkXytM6DODzTPCqr8D3VBU5lLpEtPgXBkgKHXa /2hOGRulftnWvuUyXuipytwSw9U7mKLluHiuI2eGKKOzDJMvNcvDisZLGMOROzDAh7Uh hVd5YXyHKqD/d5s5UKvVbxKujPDWJkVaSC8SE3yTLdc8p9jVgQSAyPEkMcVr65DLzepV kKUKuyHH+Uk/a7sifRBlDRV15eECINy4F4lOrStX+/JC8WdjA+o+00CXgSWvf1NejkyM UYrG9hiQyY0/FY2xKhmrOsXyLw9/BUtTM8gjXG1aMwvn/mEmrjd/ysWf5NSuaGMEWDMg nKIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738913822; x=1739518622; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y44bcrR3vjCvzlbnHWa0ro+3g7qoj/70tOjcRDEEyiM=; b=lSHheyyXjPJ/vKSOsMBjw1GBMIRRbOYh0PcFiwdlzU6+FvlLMZDtzV+Uk6OxOLaIUG 0NJtu8srfkn76JkjN7ZzyhCjBO1rycbRWJbeGwUKQ7Erzu9WEYoYEHDLmeukHEYJFSS4 4zn50xtcmTFXAE2BSPyE3Jrswg4hKljWPhrJ6W8rBoB6o1dcTo4sSK9L1Y+iSBv5bhgQ k3mFRa43OJTdSpyc1E95E82u1xAguM8B34J/eVbSHuf1wwQdg22NHWKOXOU2Wl6wQFxf Fi4JqrUwU8pWmJllHMYf5LajU77JSbCOreOwGGSNZbcRHSVdYUlnt/iMIqfjySTeEtnS zy1g== X-Forwarded-Encrypted: i=1; AJvYcCWjVL1yH9e47H5OoqMoCElh2jXzJ373zfDDzbHyyfOnTXo2XVmfNE7A04LjJfxogTc9uPZCFfnOx0c=@lists.php.net X-Gm-Message-State: AOJu0Yxoz5ETKKvCspEZkSSI34Os0B1T+nFBTddxSBqu/dSJniKWnFp2 R+bQ5LHr4VdCPNi2w5vpoQo5F1wRah+MOca+gbZVxwCfXFtzCjV65CU9ehopTA2CTrUadHVMqK9 aNqkY601T6ruT3RMEUz+yUphRbyk= X-Gm-Gg: ASbGncsC0uP9jRdny9cQIo4U7NZhgQSJ/O5TulOGy9OHPasJ/OFzR76JI45nSXuZ5tm eMq6jQWnB0E5UAmrf5Jpva/74zHwTgy20UCCSfmzuuDPudRg9iqJovxy+whs28/cX71XVKKgi8v k= X-Google-Smtp-Source: AGHT+IGxi07VJqjEkWojDOlDgGk11Ot0FjpV+JgfgGboKJoXGuS0qbSqyBYyyODwbeE2WvfW9yZYltRZBMcKpYAjQ9I= X-Received: by 2002:a05:6902:1509:b0:e58:549:8550 with SMTP id 3f1490d57ef6-e5b4626ca60mr1837681276.37.1738913821709; Thu, 06 Feb 2025 23:37:01 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 7 Feb 2025 09:36:50 +0200 X-Gm-Features: AWEUYZnGoK01cS1EIgHbR5Fdr5ePlbP2gH4Frbn4QXMKgODk3W5iXJK7QJ_L-Ns Message-ID: Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) To: Oladoyinbo Vincent Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000a3606d062d886cb9" From: zsidelnik@gmail.com (Eugene Sidelnyk) --000000000000a3606d062d886cb9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Larry, That's super! I hope it will pass! Oladoyinbo, IMO the way it is described right now (e.g. explicit closures) is much more elegant than a new way of doing things that's not so obvious and will be necessary to keep in mind and support anyway. If it'd be necessary to simplify the stuff, like passing particular parameter from the input pipe into the function at the particular position, - I think it would be possible to do it with partial function application I hope to see in the future. (e.g. bind callback for array_map function, making a new function for the pipe that will accept the only parameter - input array) Thank you On Fri, Feb 7, 2025, 9:16 AM Oladoyinbo Vincent wrote: > PHP codebase in general is quite unreadable due to robust way of doing > things. Pipe operator might make things more complicated even more... > > But after reading the RFC, something came to my mind, a way to simplify > this stuff > > What if we implement it this way: > > ```php > > $pipe =3D " hello world " > |> strtoupper(self) > |> trim(self, ' ') > |> htmlentities(self) > |> fn (self): string =3D> .... > > ``` > > Maybe 'self' or '$this' can be used as the keyword param. > > It's a suggestion anyways. > > On Fri, 7 Feb 2025, 5:58=E2=80=AFam Larry Garfield, > wrote: > >> Hi folks. A few years ago I posted an RFC for a pipe operator, as seen >> in many other languages. At the time it didn't pass, in no small part >> because the implementation was a bit shaky and it was right before freez= e. >> Nonetheless, there are now even more (bad) user-space implementations in >> the wild, as it gets brought up frequently in "what do you want in PHP?" >> threads (though nowhere near generics or better async, of course), so it >> seems clear there is demand in the market for it. >> >> It is now back with a better implementation (many thanks to Ilija for hi= s >> help and guidance in that), and it's nowhere close to freeze, so here we= go >> again: >> >> https://wiki.php.net/rfc/pipe-operator-v3 >> >> Of particular note, since the last RFC I have concluded that a compose >> operator is a necessary complement to a pipe operator. However, it's al= so >> going to be notably more work, and the two operators don't actually >> interact at all at the code level, so since people keep saying "Small >> RFCs!", here's a small RFC. :-) >> >> -- >> Larry Garfield >> larry@garfieldtech.com >> > --000000000000a3606d062d886cb9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi, Larry, That's super! I hope it will pass!

Oladoyinbo, IMO the way it is described right now (e.g. expl= icit closures) is much more elegant than a new way of doing things that'= ;s not so obvious and will be necessary to keep in mind and support anyway.=

If it'd be necessary to simplify the stuff, like passing= particular parameter from the input pipe into the function at the particul= ar position, - I think it would be possible to do it with partial function = application I hope to see in the future. (e.g. bind callback for array_map = function, making a new function for the pipe that will accept the only para= meter - input array)

Thank you


On Fri, Feb 7, 2025, 9:16 AM Oladoyinbo Vincent <oladoyinbov@gmail.com> wrote:
<= /div>
PHP codebase in gener= al is quite unreadable due to robust way of doing things. Pipe operator mig= ht make things more complicated even more...

But after reading the RFC, something came to my mind, a way = to simplify this stuff=C2=A0

What if we implement it this way:

```php

$p= ipe =3D " hello world "
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0|> strtoupper(self)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|> trim(self, ' ')
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|> htmlentities= (self)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|>= ; fn (self): string =3D> ....

```

Maybe '= ;self' or '$this' can be used as the keyword param.

It's a suggestion anyways.

On Fri, 7 Feb 2025, 5:58=E2=80=AFam Larry Garfield, <larry@garfield= tech.com> wrote:
Hi folks.= =C2=A0 A few years ago I posted an RFC for a pipe operator, as seen in many= other languages.=C2=A0 At the time it didn't pass, in no small part be= cause the implementation was a bit shaky and it was right before freeze.=C2= =A0 Nonetheless, there are now even more (bad) user-space implementations i= n the wild, as it gets brought up frequently in "what do you want in P= HP?" threads (though nowhere near generics or better async, of course)= , so it seems clear there is demand in the market for it.

It is now back with a better implementation (many thanks to Ilija for his h= elp and guidance in that), and it's nowhere close to freeze, so here we= go again:

https://wiki.php.net/rfc/pipe-operato= r-v3

Of particular note, since the last RFC I have concluded that a compose oper= ator is a necessary complement to a pipe operator.=C2=A0 However, it's = also going to be notably more work, and the two operators don't actuall= y interact at all at the code level, so since people keep saying "Smal= l RFCs!", here's a small RFC. :-)

--
=C2=A0 Larry Garfield
=C2=A0 larry@garfieldtech.com
--000000000000a3606d062d886cb9--