Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114508 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23369 invoked from network); 17 May 2021 18:41:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 May 2021 18:41:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 51CE31804B1 for ; Mon, 17 May 2021 11:51:17 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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, 17 May 2021 11:51:16 -0700 (PDT) Received: by mail-ed1-f41.google.com with SMTP id b17so8178894ede.0 for ; Mon, 17 May 2021 11:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n5+yWfr89rK/Tr19kN/6FaGPMpXp3ScSv3m0IX6eirU=; b=Y2lc95TqPde9BnN1Nmm5158PN8rPRspQK+5dpERRs0ZaB40ro0mK8r/z1u1WcacCdy xfg9K8kA73DnCnf4kQksO7aeCBcQN1TCnddjEmF5WI9tIqKSCQzjMU0t7GpmKE53X2iO xJsL0eFuvDv/0qbzraMxTwnuY6bM7+Hy096YL9N2BKnj1eGDSM+WbyyvFaORCnM83X+c e59ne2UVMvdZw39tdi/jrWKVpXWQfnuMaeqIvODdOpEfyFXEY1KD7HHu0YOPNaJW9x6s vP+snk/nzxcwA2HkRkaQtIfzu4dBTzPlPyO1urpn0UuW7B8VpIpHWDoRRb4zS8IQn9dG kk1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n5+yWfr89rK/Tr19kN/6FaGPMpXp3ScSv3m0IX6eirU=; b=J7YldbB0JJSD4U7Ch+i5Z7jRq8A4qVlxyy2p2e+j+P72FZlUMG0y8oHGJZwsmvLzeQ AIx4IDKHnepOFeq5s7LyoPSqy0EQfQkaffivcgtB59Q8R0pQbsPqOkSW0YuIfI9jRZhE mUPspS/4Wqy9YxnOiT/ijpq+HQxDSpAhqVZWVUN3xeelMPvmoXwUk3gbbZB3Zfj5hKV2 nZlZUnOX5skQl9RhPitDAjPQoljmpkCVSh5egW4kZJmrUsCzcOT7u8AlGdhxJwEJ/wT9 D1RBKuJ7HWo5t3QZ6xbuOaAdYF/jOnxtZUoe3TYd+mvZ2VUTZOcVebgiANun/2MMMnpx BYXA== X-Gm-Message-State: AOAM531XuOFtOOr9Vf2bpWIPRNzL75V6qESEyyz82IjMI9+8Az27nPGu 2cH8Tf79zI8zM6kieO9JWRWVmCVO1e1hm7s+ttM= X-Google-Smtp-Source: ABdhPJzCueV2Sz258uVZy/bbs+zTZyriprH79kJGX7LQUpUyq2EXVAbxR5bvXZt5LWms4SQkmlxMYUj0ha/6KpLYOfY= X-Received: by 2002:a50:fd81:: with SMTP id o1mr1742666edt.107.1621277475785; Mon, 17 May 2021 11:51:15 -0700 (PDT) MIME-Version: 1.0 References: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> <09B663C3-E21D-432B-BB7F-78312F827C30@newclarity.net> In-Reply-To: Date: Mon, 17 May 2021 21:51:02 +0300 Message-ID: To: Guilliam Xavier Cc: Levi Morrison , Mike Schinkel , Hossein Baghayi , php internals Content-Type: multipart/alternative; boundary="00000000000006d22905c28b1420" Subject: Re: [PHP-DEV] [RFC] Partial function application From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --00000000000006d22905c28b1420 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 17, 2021, 19:53 Guilliam Xavier wrote: > > > On Mon, May 17, 2021 at 5:47 PM Alexandru P=C4=83tr=C4=83nescu > wrote: > >> >> On Mon, May 17, 2021 at 6:36 PM Guilliam Xavier < >> guilliam.xavier@gmail.com> wrote: >> >>> On Mon, May 17, 2021 at 5:01 PM Levi Morrison < >>> levi.morrison@datadoghq.com> >>> wrote: >>> >>> > Joe Watkins has successfully worked out some bugs that also enable >>> > more powerful behavior. Thanks to Nikita and any others who worked >>> > with Joe on fixing these issues and reviewing the PR. >>> > >>> > The short of it is that re-ordering parameters when using named >>> > placeholders is now technically possible. We will send an update when >>> > the RFC and implementation are ready for re-review. >>> > >>> >>> That's great news! >>> >>> By the way, I forgot to add that another syntax might also be clearer >>> when >>> binding a value to a named parameter, e.g.: >>> >>> ``` >>> function f($a, $b, $c, $d, $e) {/*...*/} >>> >>> /* We want to bind value 4 to param "d" */ >>> >>> // with current syntax: >>> $p =3D f(?, d: 4); /* or f(?, ?, ?, 4) */ >>> >>> // with another hypothetical syntax: >>> $p =3D *f(d: 4); >>> ``` >>> >>> Anyway, looking forward to your update =3D) >>> >>> Thanks, >>> >>> -- >>> Guilliam Xavier >>> >> >> Hey Guilliam, >> >> adding a special character like * or ? before the function name is >> not going to work. >> It might look good for *f() but it has the same issues as casting. >> >> You should be able to have with the current version a code like >> $actionGenerator->getDriveAction()('home', ?) >> You can't really put the * or ? before the function name here. >> >> Maybe having it just before the parenthesis would work. >> >> Regards, >> Alex >> >> >> >> > Hey Alex, > > I was thinking of a (special) new unary [prefix] operator (e.g. `*` which > currently only exists as binary) with a higher precedence than `()` (if > that makes sense), which indeed means that e.g. `*f(1)(2)` would be like > current `f(1, ?)(2)`, and `f(1)(2, ?)` would require wrapping as > `*(f(1))(2)`. > A lower precedence would require wrapping as `(*f)(1)` for the simple cas= e > (i.e. most of the time), which moreover would probably be problematic if > you have both a `function f` and a `const f`. > > Just before the affected `(` might also work indeed, but with another > symbol, as `f(1)*(2)` [and `f*(1)`] already means `f(1) * 2` [and `f * > 1`]. Maybe `!`, `@` or `~` would be unambiguous at that position? > > (For both, there's also the possibility of choosing not a symbol but a > keyword...) > > Alternatively, `f(..., d: 4)` or probably rather `f(d: 4, ...)` would > arguably still be clearer than the current `f(?, d: 4)`, but still wouldn= 't > really solve the "weirdness" of `noParam(...)` and `threeParams(1, 2, 3, > ...)`. > > Sorry, I didn't intend to diverge so much. The gist is that I (too) don'= t > like the current "duality" of `?`. > Actually, the current form is not very troublesome to me. In terms of partial function application, it is fine and it serves the purpose good enough while having a simple form. The issue is that in recent discussions, also considering that parameter re-ordering issue is done, it appears that we can use it also for other use cases like simple pass-through adaptors between two interfaces. And because of that, I would like to have also a partial closure where the extra parameters are not passed further. And that is currently not possible. Whether this feature is considered out-of-scope for partials, that's for RFC authors to decide. Cheers, > Alex > --00000000000006d22905c28b1420--