Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114507 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14581 invoked from network); 17 May 2021 16:43:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 May 2021 16:43:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6B3161804CC for ; Mon, 17 May 2021 09:53:14 -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-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 09:53:14 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id v5so8061495ljg.12 for ; Mon, 17 May 2021 09:53:13 -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=HXM4ji2gF7WSZ2n+H3EnkaWKq5NS+9mtkkwiscVow2w=; b=eLuSAEV/45jmgly+PIWsQqRbVy/AXB8k+hy2XcuEZtmnn3bMmQU+4nsHJpXj9he3PG HpO60qUXacjQOxL2lBWojTgQTU1S4Y+t90HkzgVwXYfg2eL39RF37rEUXawv1qLiDDmT QIleXxIHbYOOAPayMFDfUOyNB6Avmol7/PnyTWV77061uX96N+5MJG3/Ik7RaV4m1Ysp 14jR8N/AWWUtJNpq1oYVARtwRW6U0F7yMZMnvkcYFM33Bc/tfN2rjrXqaZgQsVbpXA4u rZGKImlR4kBJX8YobYEGrUEEZFr+u9xjF/I/Dqt6hvLp+zryi/w1DjUfmKf9TVtASo2m K0Gw== 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=HXM4ji2gF7WSZ2n+H3EnkaWKq5NS+9mtkkwiscVow2w=; b=WvJCpgroxQlI3dbP8q1ZfQwxnImAXY907xVHKPhZK+VtqaIL2QCKZSqnAqkRl3euTd swx4QzpaYviLvJtpqnhiukD3imIPDe1fil47Sc8yGPXXfb1HIjcCOtTPvT6QMvL1owiO 48ZanbqjBvfFlhVHfV0Z8P9mk/BZqY1anGV7sdQCScxpnC9kowoNa4RyY0ZSUVIJTm+S /QhdXcPAXv8iGHKA6xiN5ZawvhzrwRf5e00mt5MMz1qRW3XWFjnhqMEwu9Mw1e57pWG5 LCF8Nu8w2fbnZs69vNycxjnZIleWbsvH34Rzz5SqEjxK6+LoWYsYf2Qm7rQEgLkVATWK dMZg== X-Gm-Message-State: AOAM533ed1nvVbd/v868mAo3abgJcqEEmBbyNsQc17smOmPmmo4pbt6l oRKSeBq393EjjoOE2Q6qTMdQrNz3jkgxi9ADvw== X-Google-Smtp-Source: ABdhPJwX8Orq/5y0dLmwpA3svSRo0x8BhLovCm5UiQVLwgNr5+ttdQcnXP/s6gL6YplNAx5p87hWvfmKIESLmT6b2PE= X-Received: by 2002:a05:651c:2cd:: with SMTP id f13mr312169ljo.76.1621270390264; Mon, 17 May 2021 09:53:10 -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 18:52:58 +0200 Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Levi Morrison , Mike Schinkel , Hossein Baghayi , php internals Content-Type: multipart/alternative; boundary="000000000000b254f505c2896df7" Subject: Re: [PHP-DEV] [RFC] Partial function application From: guilliam.xavier@gmail.com (Guilliam Xavier) --000000000000b254f505c2896df7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 > 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 wh= en >> 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 case (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 `?`. PS: when I write "current" I really mean "in the current state of the RFC". Regards, --=20 Guilliam Xavier --000000000000b254f505c2896df7--