Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115126 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11682 invoked from network); 24 Jun 2021 16:53:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jun 2021 16:53:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F0EE51804DB for ; Thu, 24 Jun 2021 10:12:30 -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=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 ; Thu, 24 Jun 2021 10:12:30 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id t3so9580273edc.7 for ; Thu, 24 Jun 2021 10:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=SjaC5wrvqEILP2jdGt5eb5CAZ8IR9/XCY2s7lU+GlKg=; b=EBcdiHgZLl7S3YPU7TvdIWo4l9eBS5DtaMT8sH2CNQ5gPF/QSV8+QlbPFTKeOtG/Gc iz4ngCrduj2kkK65JdvitZr9K2CeeMMaRSJY9Rlx2LNFDGcNCiEKeTJM/V7n/Mcg+s9n pLhjVRNiMlUT9OUV0oY9zl9RgxAQM6D6xHib/CeH2k0LVu1m4Sphk8++ca9/W8v9yKtG jm4TuOWGoK6a79P4++w4sXSUF75w2lqILVQYxF6zFjthU3L0rEZ5LTH0gTiBxlvtCJ5X B4aDFUrgAVg9WMJKnIiH4MffxRfJsUFNQMjBmLrDxstqiEfQ5tXGVzfRfMni6x79mTWs nICg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=SjaC5wrvqEILP2jdGt5eb5CAZ8IR9/XCY2s7lU+GlKg=; b=HrwTbmKWzFAMLmzxWJLiutZS9uthr5dN2FY2jUIw8kHGVQan8MFuLkFew593DN7BbB vi3wbfVYm1xO46Ae70wa7QWEI3gp9koKEbbko2i6DO+btAflfMNtsx3e5d0DsEQVB5GM 2MJF7tLnkYgFpyW+U7smfZHpzkgxe/VMogCS+qZVjqRp+PUQX4Cnruhx1AqpeQYm0H1k 5oj4GQ/O0o/h6INhtMqznOnJYHHrcQeUOBREhLnGED0BkMozVc4CEvovMwynjQOs32Pe e5z3fOUpliGMXABXiMvLMkkHuciK3EyZD9QpXdOzhhlf10nfTjTWPUpMLKoX1wOOBfcF 5UrQ== X-Gm-Message-State: AOAM533ZWuoBXdUWDvLEUfLcLApXCS8hQ+My7OXVnsNxWfU5dQ5CmNFl a09Zd5c8xRsCIf524sls5+bknUd5tQE= X-Google-Smtp-Source: ABdhPJzcV69uNfQAjKIGkvOaF8OXs5/d/s6aLVBtNA87N9yILr4RRdvBUFor4CpJNF7M2IN8IYnohA== X-Received: by 2002:a05:6402:220d:: with SMTP id cq13mr8524293edb.214.1624554749289; Thu, 24 Jun 2021 10:12:29 -0700 (PDT) Received: from claude.fritz.box ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id c6sm2254737ede.17.2021.06.24.10.12.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jun 2021 10:12:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: <919141bc-9b59-48f4-929f-6f0434dd7317@www.fastmail.com> Date: Thu, 24 Jun 2021 19:12:28 +0200 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <919141bc-9b59-48f4-929f-6f0434dd7317@www.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: claude.pache@gmail.com (Claude Pache) > Le 24 juin 2021 =C3=A0 18:02, Larry Garfield = a =C3=A9crit : >=20 > On Wed, Jun 16, 2021, at 11:16 AM, Larry Garfield wrote: >> Hi folks. The vote for the Partial Function Application RFC is now=20= >> open, and will run until 30 June. >>=20 >> https://wiki.php.net/rfc/partial_function_application >>=20 >> Of particular note, a few people had asked about using ...? instead = of=20 >> ... for the variadic placeholder. In the end we decided not to = explore=20 >> that, as Nikita explained off-list it was actually more confusing, = not=20 >> less, as it would suggest "placeholder for a variadic" rather than "a=20= >> placeholder that is variadic." Otherwise, it's just more typing. = The=20 >> syntax choices section of the RFC has been updated accordingly. >=20 > Since some people still don't grok the use cases, I've written a blog = post to make the case for them better than a detail-oriented RFC can. >=20 > = https://peakd.com/hive-168588/@crell/the-case-for-partials-and-pipes-in-ph= p >=20 > There has also been some positive Twitter chatter, as well as the = level of +1s on that post (which is, I think, the highest of any PHP = post I've had on there, ever), so I think the demand for it is = definitely there in the ecosystem. It's just not people who frequent = Internals. :-/ >=20 > I'd say there are definitely people that want to use partials. >=20 > --Larry Garfield >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 Hi, In the blog post, you are not fair when comparing: ``` Request::fromGlobals() |> normalize_path(?) |> oauth_check(?) |> parse_body($dbconn, ?) |> $resolver->resolveController(?) |> controller_caller(?) |> response_handler(?, $theme_system) |> $add_cache_headers(?) |> send_response(?) ; ``` with: ``` Request::fromGlobals() |> fn(ServerRequestInterface $request): ServerRequestInterface =3D> = normalize_path($request) |> fn(ServerRequestInterface $request): ServerRequestInterface =3D> = oauth_check($request) |> fn(ServerRequestInterface $request): ServerRequestInterface =3D> = parse_body($dbconn, $request) |> fn(ServerRequestInterface $request): ServerRequestInterface =3D> = $resolver->resolveController($request) |> fn(ServerRequestInterface $request): ResponseInterface =3D> = controller_caller($request) |> fn(ResponseInterface $response): ResponseInterface =3D> = response_handler($response, $theme_system) |> fn(ResponseInterface $response): ResponseInterface =3D> = $add_cache_headers($response) |> fn(ResponseInterface $response): ResponseInterface =3D> = send_response($response) ; ``` I would write it the following way: ``` Request::fromGlobals() |> fn($_) =3D> normalize_path($_) |> fn($_) =3D> oauth_check($_) |> fn($_) =3D> parse_body($dbconn, $_) |> fn($_) =3D> $resolver->resolveController($_) |> fn($_) =3D> controller_caller($_) |> fn($_) =3D> response_handler($_, $theme_system) |> fn($_) =3D> $add_cache_headers($_) |> fn($_) =3D> send_response($_) ; ``` The version with partials is still better as it has less grawlix, but = the difference between the two is considerably reduced. Style can make a = big difference in readability. Also, without pipes or partials, it could be written as: ``` $_ =3D Request::fromGlobals(); $_ =3D normalize_path($_); $_ =3D oauth_check($_); $_ =3D parse_body($dbconn, $_); $_ =3D $resolver->resolveController($_); $_ =3D controller_caller($_); $_ =3D response_handler($_, $theme_system); $_ =3D $add_cache_headers($_); send_response($_); ``` where my `$_`s play the role of your `?`s. (I still do find that pipes and partials would be nice additions, but it = is not something that I am desperately craving after.) =E2=80=94Claude