Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126319 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 8AE391A00BC for ; Fri, 7 Feb 2025 07:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738912376; bh=uKG9MvS3PPbvlhntQEokd65JwxnfEke8OvZ6bdHUzjY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dI8NMYAcUObG5HWleJXCLsn82+VuIPa9zrQJ2XgxwdOit5WpWJyhobdausdcJHFz6 dZt3XV3YLrsX5QuoYTw+udhn+8VsewgS5sno28cpr9cKpq/eMddPPw0LSjPM9SB+AE h6dVqPYlCmrOlubftmvzYjX3evhHNncm5RNamw2RflGHBGbh9TJzCI9o0nVJuoEIdN Az78ZSBag7D+wlKZ2UpJ7hQTrl/PqUuMA4S24nV+LusUsPUKMwoFsNz6gZNPfZGRM0 R75aqQhISO5Ls/QZlLXPHR35rRpOdS7lvx8WUHr1qGjAJgi7nIIr6OmZj61bX9zELS 2VHvJT8alZB3Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 825F3180072 for ; Fri, 7 Feb 2025 07:12:55 +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-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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:12:52 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-53f757134cdso1863191e87.2 for ; Thu, 06 Feb 2025 23:15:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738912536; x=1739517336; 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=/NT2GGqlQrUDXtufbLOC7e+ZMgMhfbKmk5lSoa9dwi8=; b=KJBaMhHgrk4Q8BJFAKmwMA04F+ZcZNbhoynoBYZKMXDKvN5TLVxDXApsVxKYO95mjI oZQDGm1FmhBVbOuWa2LLdzHQznq1ovi48xpe8n6kkqR72EIbCW5gyPkVRvp6vu3IIevi EQTlNkr7Z2c5SSatkoRVSPdUUOuoKdSFRDXac4TiX99bMfXuMKSigXiv7bJ0gmQ9WmYa YReX24PcLlFsm6+JgYSCUCJLp5+2Jd1ZiDHxw8UtKpntAZVP4Bs8s4aahUx0j7wLeFAW EoOKyXS2PAsDhNUY5IrCseCA1WkCoV+aDZQkdEBY3n7ggroLNGGxGfXmS4NL5+gfVweG TmJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738912536; x=1739517336; 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=/NT2GGqlQrUDXtufbLOC7e+ZMgMhfbKmk5lSoa9dwi8=; b=n2EFe3IGjg6J75N1N9MkBk0LGoAR3/jjAqotZAzQFyxez7zYHtc5Sw9Pnntsy8oNYf 6Xvsdy1JW1HiP744ha8kiXkEJZYm+6oct+FS4rzepdisCy1j+ZZWAOKfQyWP44ImlQmR spni8Vf3hDkJNU7COmFobL5l4wQ/K/tz9BhDyaPy/H5ceMvoStEPGKN1K3ZgJDlz8ChL Uk6WouucGxMQYSR5Xv7K/wgJPiae+OV3iQFWsN0iFfg1N8oG9L2YAZ/UBuPBvX1rvTts l91iMFpdGH3KU2NidgALszW3AN0tC0It2FzMa9BR7SDOApUGXnttCi7syYBH8/vpudri djHg== X-Gm-Message-State: AOJu0YzqSoglym0vtbrYEMBYxWNzmioaijBTpcXqvf9EB+zSrCKW2dPZ 1o/7p1Fho+hth6Y1m+n+rCQ8ZBmdVu0CECYtBDWjz7+fbre8DMWKovvJcnyUZ7eJYWImI4dF9mF 1lLN6rPh0of4DBnWfHClSu/mtjF6mi7v9xHU= X-Gm-Gg: ASbGnctuAV5yicob9TSg9nj2rjzcKfdxjzBRTtglW5pbSZbczoM47AEqM4azXPJ7DTX 8DfI0MEyTOJ5DUn4BXs49I3/koYqO7Is76Aq5evj3demciM7A4cxxZ9+s+FyvX0wAGwIDgMVUtA == X-Google-Smtp-Source: AGHT+IFII1bF3PkdMpAxAb1lajK474IJ4dytQkJw5sxOBqehfe9dAxqYogdal2LRB9D41TxH/QcPg4ztNu/ysEmnExQ= X-Received: by 2002:a05:6512:1282:b0:544:d31:104a with SMTP id 2adb3069b0e04-54414aa8102mr484943e87.25.1738912535275; Thu, 06 Feb 2025 23:15:35 -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 08:15:21 +0100 X-Gm-Features: AWEUYZmLdknFlRiGqLOoVkKzF0Dh4rpzhPk4o-2nWxl119_cFmLe22yYJoT7r8s Message-ID: Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000f5f405062d881f57" From: oladoyinbov@gmail.com (Oladoyinbo Vincent) --000000000000f5f405062d881f57 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 i= n > many other languages. At the time it didn't pass, in no small part becau= se > the implementation was a bit shaky and it was right before freeze. > 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 his > 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 als= o > 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 > --000000000000f5f405062d881f57 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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=C2=A0

What if we implement it this wa= y:

```php

$pipe =3D " hello world "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|> strtou= pper(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> ....

```
<= br>
Maybe 'self' or '$this' can be u= sed as the keyword param.

It's a suggestion anyways.

=
On Fri, 7 Feb 2025, 5:58=E2=80=AFam L= arry 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-operator-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
--000000000000f5f405062d881f57--