Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114518 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38506 invoked from network); 18 May 2021 20:41:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 May 2021 20:41:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AE2B91804B1 for ; Tue, 18 May 2021 13:51:08 -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,NICE_REPLY_A, 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-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 ; Tue, 18 May 2021 13:51:08 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id i17so11651463wrq.11 for ; Tue, 18 May 2021 13:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=0smFlk1hUVSsgUCpp9jAK7+RUgfsWUFbLjcW/UaijM8=; b=DM1r4BfAUeSKOVESclQCEuqmVvM1qBbmUjZQCZJoqZdm2WThJuELrIFsZrv+OPZx41 VdWI3yuM5wNmsiQpLIBicdnoo93u6nkwPIBb5CnAE4Fw+uAk/8aL/LOJOaaJ0Dvctbwy 7QRjI1LB1RmjoV8p8ORWoeSGgqJ589bn5EdLvjnlN8K32398rqxxgsUgu+20yrBElRno fl36IxNweQsIOKMIGtZHjtqEgfbHBNj2hA6bWUkH9lPOqPDsF+EkcrdU2kQrnY9T20cY fwT+S2FYHEVemgCmQD6g1GhqA1pnDtMQcJ/0j+ftPBGBPsfcLMbnhnB/RxFhgsCZatFo dMXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=0smFlk1hUVSsgUCpp9jAK7+RUgfsWUFbLjcW/UaijM8=; b=hegvUcaHWCTj2BMlR5k/XK++MK6xe0zD2ELmaTTew6yI5pDCSMNp34e7+BZDeEnw+X k0ZnvK+GOm2CvVStmxT1C4iNzTtfYcqnhl1wwPwrojSwBolmHw6gVnY/Y/35SzuDa8Ce n0d4Nr6IBEkI3+MyHedoq/SLBkMR18eC+8uP82BmAOhW+WH0+ykL3Z0RYDW0ag8wUvJe Jej/DE+69165XOAMUuHgUwGwQFPa6TnDluWEoFTX16cK+6yMeHDG95vJ7st+MKc8soaW cm9sZS59Dwlzagt2Q2ce9JRhF53ClFglPwzi70KLoIBMNhJiIhotHm/dritbaggYM71j 66QQ== X-Gm-Message-State: AOAM530gh8IFF/OQLx7U6tUakLThc7UhGFeuL6oAp1+zQPe3JdJsmUmv gg/BW0D7CMUgAnJ4eiR+WkAhcW8j57I= X-Google-Smtp-Source: ABdhPJwvXs8yOaETa5rnoQ3usO+rwRhtABErfOuCde1jIvLGvgLbAK9tRSYVMXpY3BkOEw4t5g/m6A== X-Received: by 2002:a5d:6551:: with SMTP id z17mr9426360wrv.372.1621371067098; Tue, 18 May 2021 13:51:07 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id v20sm19355268wmj.15.2021.05.18.13.51.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 May 2021 13:51:06 -0700 (PDT) To: internals@lists.php.net References: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> <532D1413-52FF-4403-A20B-BBDB51163C85@trowski.com> <9c83ba12-79e1-4fc6-9a75-7a6b04965f03@www.fastmail.com> Message-ID: <38aa478b-dfd8-f62f-7803-5fc9499e5077@gmail.com> Date: Tue, 18 May 2021 21:51:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Partial function application From: rowan.collins@gmail.com (Rowan Tommins) Hi David, On 18/05/2021 20:56, David Gebler wrote: > function foo(int $a, int $b, int ...$p) { ... } > $partial = foo(?, 10); > > $partial(5, 15, 25); > > Intuitively, because the existing convention is extra unused parameters in > user defined functions are silently ignored, I think I would expect the > above to be equivalent to something like: > > $partial = fn(int $a) => foo($a, 10); > $partial(5, 15, 25); // 15 and 25 are lopped off to no effect > > and not > > $partial = fn(int $a, int ...$params) => foo($a, 10, ....$params); Did you see my message yesterday about the two mental models of the feature? https://externals.io/message/114157#114492 Your expectation there is in line with the "start with an empty closure and add things" model; the behaviour proposed in the RFC is in line with the "copy the full signature and then splice in fixed values" model. I do worry that users of the language will assume the "wrong" mental model, though, unless we pick a syntax that more clearly matches the "copy and splice" model. I think that would mean having a way to say "make this is a partial", and a way to indicate which arguments to "splice", without any "placeholders". Yet Another Bad Unsolicited Syntax Suggestion: $partial = partial foo(); // no bindings; current RFC $partial = foo(?); $partial = partial foo(b: 10); // bind named parameter $b; current RFC $partial = foo(?, b: 10); $partial = partial foo(1: 10); // bind positional parameter #1 (zero-indexed); current RFC $partial = foo(?, 10); Regards, -- Rowan Tommins [IMSoP]