Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116643 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53436 invoked from network); 14 Dec 2021 08:19:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Dec 2021 08:19:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9CF7F1804A8 for ; Tue, 14 Dec 2021 01:21:33 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_20,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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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, 14 Dec 2021 01:21:33 -0800 (PST) Received: by mail-wm1-f52.google.com with SMTP id 137so13740250wma.1 for ; Tue, 14 Dec 2021 01:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=e5pg2EnQCapobBT9tORLSZpjMXRgx4DB3AkiqZYqxc8=; b=I+WXX8xEzpc5swg/JPUuWW0FdqGsdVMtJlWS6e11M4Pu5X9FMQEva5LFE7l+L4cl5U 9wH9PCX4YCAWtK8KpukrMzgce++///jPx2tiMDxoPIOljb4zWo9hjg6a2vOPzNakOj1r PzZqbcfMGr4zISXZ8nuZ7Vuz+P1VoAKjUOYeC4hxMFmTZNaptl4hT/Y8URaRg3pW70uc smr+VYQ/FH9VTLdH/OxRaJN6uZSEY1sS/EYeJ9HICFc+UgifNZiUIecNO+7W6/p5v3ig QUxu5Ynvnb/KBWX19I1ljnStLGmGwX41TAKGDzS4OPaDh6qYb6Le8v6PtY+DixEYXzMa oApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=e5pg2EnQCapobBT9tORLSZpjMXRgx4DB3AkiqZYqxc8=; b=UhzBm7MfKgnY8q3HX1M//gJSMCY6EfnIu6/OSZQ/UYN3LLzxigFPQdBYjq+IA4PTUw Ihr1JZAbxpWvcYkGbkLZVMsuaJPOkpZckZwXNbmc3tXmmfJnurmpmUvgxKBA1SZEXaYh qovNTFeXNDvvhmXMkZ75I+uAlHYRA37JXWBiOoRq4/2ox0x4jndOLx1lSjWtUM2Haz7w hEwRR8LbgkIzTj+V8c0hfoEvlMgJCvpdJaIXq5rzzVkBLeOUBpua/4FtR93J9dUgZHSf HqtQWchetwFaD/oGtA1kQPRkbg4RYoCsOJ6aPp9b9umXqB6iyWRrgmMLsKxjeEz2KU1T jAtg== X-Gm-Message-State: AOAM5329vUkeJB5fZ09r6Ifud/6SFVfGtYZb6d+taWgEAdKFqLCv7hij 09YkA6E/79TzCtoRhCPj4gpYcTWpYMY= X-Google-Smtp-Source: ABdhPJzPQVMy7Snk80z9wlBYEK5mEleBbBxyBX98qYlwEgSDfKUrokSwdWmZteR9ubax3z1cNYxXlA== X-Received: by 2002:a05:600c:1e06:: with SMTP id ay6mr5704251wmb.64.1639473691933; Tue, 14 Dec 2021 01:21:31 -0800 (PST) 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 p19sm1795350wmq.4.2021.12.14.01.21.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Dec 2021 01:21:31 -0800 (PST) Message-ID: <2e212c5e-4b3e-985d-b2b1-9afe0782e7b0@gmail.com> Date: Tue, 14 Dec 2021 09:21:28 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-GB To: internals@lists.php.net References: <02ba01d7ecbc$c0e13370$42a39a50$@webkr.de> <1639437120.436292407@f322.i.mail.ru> In-Reply-To: <1639437120.436292407@f322.i.mail.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Allow default parameters before non-default ones? From: rowan.collins@gmail.com (Rowan Tommins) On 13/12/2021 23:12, Kirill Nesmeyanov wrote: > I'll add that leading optional parameters are needed to implement currying and partial application. > > ``` > function foo(int $opt = 42, int $req) {} > > $foo = curry(foo(...), 23); > > // $foo = fn($opt = 42, $req = 23); > ``` I'm confused what the optional parameter is doing here - is it just to avoid telling the curry function which argument you're fixing? And wouldn't both currying and partial application result in a single-argument closure there, not just making both parameters optional? I would expect it to look something like this: ``` function foo(int $a, int $b) {} $foo = partial(foo(...), 23, 0); // $foo = fn($b) => foo(23, $b); $foo = partial(foo(...), 23, 1); // $foo = fn($a) => foo($a, 23); $bar = curry(foo(...)); // $bar = fn($a) => fn($b) => foo($a, $b); ``` > While this is not a popular practice in PHP, this deprecation notification «breaks» all code that uses functional pradigm/concepts. That's clearly an exaggeration; it's clearly possible to write functional-style code without making use of this particular trick. If it is a *common* trick, then that's worth considering, but it would be good to see some evidence of that. Regards, -- Rowan Tommins [IMSoP]