Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119692 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 259 invoked from network); 14 Mar 2023 12:57:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2023 12:57:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4595C1804DF for ; Tue, 14 Mar 2023 05:57:04 -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, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Mar 2023 05:57:03 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id k25-20020a7bc419000000b003ed23114fa7so4386775wmi.4 for ; Tue, 14 Mar 2023 05:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678798622; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=OQ8ZMHHzwfaCXTq8FQM2zxQBw7JVroQefoHwwNIjckk=; b=JBt+z+3H/dJJXyyUWuUvHNYTxV+181ioCUWQdskGE1OUkDnp3+zPZJ9ntRtDnRHxan zttMjoFVU5/X+mFbefXqjbckriynik4oX5fSIEQA97MdbSOMqSOkDYxeHOHNrrltrV86 HZGvdtNzf2ZAhoVYTKJIfKpmCqs4O9vy4UUAUtrC5DPYAaPJv6EPlyCZ1BhdKT5HsKl7 PgkZCMi3chqe0z77LDSBpGk0h515tdzYfEdg6fDHEH0GIkEOBGg25BOGHJIWFIctrNOM uETc+z7x5qoZsy0T1mBBd+JUhMHXANeDHQT0ewvT5sVsQszuOS0bAXFTyeY3o6MWsv6w FeXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678798622; h=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=OQ8ZMHHzwfaCXTq8FQM2zxQBw7JVroQefoHwwNIjckk=; b=DRoxledZ9fb6nSv16QdAAOX948ZEP8scX4TyMEonDCTJa30fE3E4mlRiVlWrBzGFfW HczmbTT8BIuf/vxpBRe8TePxyECvPSUUwcY7MosORSSepHobh9BQwkg9e2TPUmL/EgLw Q85ZU6pKYszlHxmn6la+f8cDk237ABAnQZnDGMUoJgdfaGcxB3dlV+0iGwTUVZleOgSi 9A5ZAoFWPP6mkyGdl8OfXaGLoEdFEjNGnykXdBqjLbIIdUB4S7lGqIehJLFRl62ldm8o FQgC6TfS6fy2AIeMHhsU35GHQuAbaMIOB3s9Nrb6tKNmrP3haJbWPXbD4BTAJFVs3w4K rnZg== X-Gm-Message-State: AO0yUKWpJp5U0koMirUarEN0PS+z+Myt9h9ZQkzuOdy7/xvYyV9dMxql /2pRowPHd8JALJ9xoiXbrzLN67bNK1n5e7OXnogZ3ifMiAQ= X-Google-Smtp-Source: AK7set8zod3n7zOd0KNc3olfbUEDD5l9JoL41tLb0oHgPK0AFihIIGS2Zi2MPItPzdRz/8J06GhlaN7HBvEiH/gqnNw= X-Received: by 2002:a05:600c:54c4:b0:3ed:2a8f:e263 with SMTP id iw4-20020a05600c54c400b003ed2a8fe263mr689637wmb.0.1678798622110; Tue, 14 Mar 2023 05:57:02 -0700 (PDT) MIME-Version: 1.0 References: <9975B833-EE24-4ED7-B28E-841B92988BA0@cschneid.com> <1A2CE63B-ECCA-403D-83AC-B1E26279323C@gmail.com> <9a2140b4-97bb-4a9c-90c5-809274c83f75@app.fastmail.com> <88c4a63c-859b-94d5-e314-3399fb2c3fb0@gmail.com> In-Reply-To: Date: Tue, 14 Mar 2023 12:56:50 +0000 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="00000000000085393105f6dbc306" Subject: Re: [PHP-DEV] First-class callable partial application From: rowan.collins@gmail.com (Rowan Tommins) --00000000000085393105f6dbc306 Content-Type: text/plain; charset="UTF-8" On Tue, 14 Mar 2023 at 10:39, Bob Weinand wrote: > Hey Rowan, > > do we actually need *positional* partial application, after a ... token? > > Would it not be enough, to simply forbid positional arguments after a ... > and just allow named arguments? These already have well defined position > independent semantics. > > There may be some desire for a single argument placeholder later on, but > this can be introduced later, separately. > Yes, named parameters would certainly be better than left-to-right only. It's definitely less elegant, though, and given that PFA is largely short-hand for a short closure anyway, I think conciseness is quite an important aim. To take a couple of the above examples, and compare existing short closure, fully positional PFA, and named-after-placeholder PFA: $isLogger = fn($object) => is_subclass_of($object, LoggerInterface::class, false); $isLogger = is_subclass_of(?, LoggerInterface::class, false); $isLogger = is_subclass_of(..., class: LoggerInterface::class, allow_string: false); $priceFormatter = fn(float $num) => number_format($num, 2, ',', '.'); $priceFormatter = number_format(?, 2, ',', '.'); $priceFormatter = number_format(..., decimals: 2, decimal_separator: ',', thousands_separator: '.'); Arguably the named param version is more explicit, but in some cases it's significantly longer than manually defining a closure, whereas fully positional PFA is always shorter. Regards, -- Rowan Tommins [IMSoP] --00000000000085393105f6dbc306--