Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119736 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97978 invoked from network); 17 Mar 2023 10:35:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2023 10:35:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D86C21804F7 for ; Fri, 17 Mar 2023 03:35:58 -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-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 ; Fri, 17 Mar 2023 03:35:58 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id q16so3985716wrw.2 for ; Fri, 17 Mar 2023 03:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679049357; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=D+RNkXlLq2X7a13VqktvFY0Mek21pdLgYZArvn7MkOQ=; b=hK8Y7p1ArO5uf5IGgD+P4+RBpbhaaotmqeGI0vD58HoAnopVYqTmj+nWxayB04f/cO uRewJUfuyuGTowOPlwRf7b+l+c1eUNmR3WYuvzii6FvRRSWbC33F002Exlr8ha7k9AjI t5fTna7YimMa4s7DQuNKPcKhqQgCCXx8eYDif+JRFZvrgecaZYma8G9gd/Y8xQma3XNs SMQP0zg8HfvU6j6TPBjqtpyX+/7lakpcQlp2HgxGPg42xeqdX07oo+yamHEDLOy0VCF8 sYg0E1qXwjYNN4S13d3lyPu6oxTj5HwIMxbjSeGOZWRzGkyoJOV2jt26E3hk7Wli+CTQ xpRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679049357; 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=D+RNkXlLq2X7a13VqktvFY0Mek21pdLgYZArvn7MkOQ=; b=U7VwJyMcRYeIVxNotLMZEH6nEHGvHS9iGTljNAL47BH+oly1HCnSbF1QmuutZaMAWg 2o/KsqmwsKRNe5JVmdwB5LxNVjopRA0nH3E6S4AaYlzaSDyKjsJ/z0khLR8VN0kv3NDa d8u0ruWHcLsy95bVzp/t7v6R0sWR0ZpIQduwOwGAQJmVDLFP72anF4Kgr1AeN+nsLAh4 T+fMcU782YdNBPqETbaM8NK4Kfu0LJtyjbX/gA2tjbNjw+V2CqbBGT3I3TkKw5YYyFCy YNDMNeVhJSBsZ/GrO/o9U0ZiF/xcbPccOZc2zE9SjVWDqq3qWNCinuxdKbkpEKqQWCQ8 QHIw== X-Gm-Message-State: AO0yUKUKJIRx/rcZHIsndDNMflDI0g8I0fXO/1iFC4qf2hygZ7Vi6LeJ NWBNByY5p2F+MLRjK8vFYsp2BjFkryvwNirBBOactqPzsgY= X-Google-Smtp-Source: AK7set/C4OJ15D7EM3yGYwG1NwqOTSwJjYSUzXLbhTQeIhYDrq9Y7rrdCuRyPb4e/m0a5JnLCn8guH9e3cpNgu/TPaA= X-Received: by 2002:a05:6000:805:b0:2cf:e4ae:7158 with SMTP id bt5-20020a056000080500b002cfe4ae7158mr712036wrb.5.1679049356970; Fri, 17 Mar 2023 03:35:56 -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> <1a4d4434-7318-4831-9fc0-8b48a6400a62@app.fastmail.com> <73033e11-a521-40a3-a29e-14d575332aea@app.fastmail.com> In-Reply-To: Date: Fri, 17 Mar 2023 10:35:44 +0000 Message-ID: To: php internals Content-Type: multipart/alternative; boundary="0000000000007b8f5605f71624c4" Subject: Re: [PHP-DEV] First-class callable partial application From: rowan.collins@gmail.com (Rowan Tommins) --0000000000007b8f5605f71624c4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 17 Mar 2023 at 09:52, Robert Landers wrote: > > I think this is already supported-ish. For example, here's a partial > application in user space that seems to follow all the rules. Or at > least the rules that are followed make sense. > > function partial(Closure $callable, ...$args): Closure { > return static fn(...$fullArgs) =3D> $callable(...[...$args, > ...$fullArgs]); > } > The big difference between this and a native implementation is that the closure doesn't have any information in its type signature. As well as leading to less helpful error messages (type errors will be reported as happening _inside_ the closure, rather than on the line that calls it), this makes the parameters invisible to Reflection. There's also no way to make it an instance method from userland, making everything a bit verbose - Micha=C5=82's example would become something lik= e: $size =3D Closure::apply( Closure::pipe( Closure::partial(amap(...), chr(...)), Closure::partial( implode (...), ','), amap(...) ), $arr ); Regards, --=20 Rowan Tommins [IMSoP] --0000000000007b8f5605f71624c4--