Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114517 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32912 invoked from network); 18 May 2021 19:47:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 May 2021 19:47:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D56FB1804E3 for ; Tue, 18 May 2021 12:57:03 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 12:57:03 -0700 (PDT) Received: by mail-ot1-f49.google.com with SMTP id s5-20020a05683004c5b029032307304915so2447009otd.7 for ; Tue, 18 May 2021 12:57:03 -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=qBi+pS0A/1W1ak4dxLeJymSxnoM3oSXjahzIztZNGcc=; b=UbPzEahDHc4W1g3Z89R1ZMS1BsSKZOCcdr2C5Ry/yY2fIXczD1Ll+24JSCkGOK5uHB vAlVi5haRg1mr3dbk2P8ecvkzwg65oWYS4eZd6mXSO39ClN52qrVYo4RqffN1zVZo9nb s6rLdLhW1dSer05VeAFpXeENOrBZeKu8pVHai6LFYaG4C+VcmxZSQpzx4vnr20mciqm2 +0x8PLiQP2MlxHKVqpIFqqgN0l+lOKop5VRKax42AdZqFaVgcVxr6jRM1CBqjDb8m2LZ a6XrAA32gNYpsa3PXP9off2lcXNWQDs0ooOsVvxwYDX0vz+Mq4QK0VV+pnCD15Si0lop QZEQ== 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=qBi+pS0A/1W1ak4dxLeJymSxnoM3oSXjahzIztZNGcc=; b=Yi7+hKLRdtWTFLRG1zS24UeI+xgzroscFusctNWGdgoqzJRgeyz2Re4tyhqVQexi4K mOZ0/kxJGRRDhuuaUMZwqRIjX5uaC3s64P53U+E+tszOn6V5wvfuzcQvnH1Folw1OlTb bJHzHI3E47XIRzKQEodNU/h9tFccg7HZ+TXSJrV6UjJsVyLnbl9zish+D0c1bMgH1nza geCrCT5wNTv4zE6wI2/nf+NXJTFMjez6RSSwRDF5isSXL4OwbgZnmd9hhjmqHkNM8dTg +pMUnKp+KgBR322j6VIVgwSzR3ZRdtUIiRxGwuwWIw5kIhB6KE6fzfe9oFwJv01nNxJz QqEQ== X-Gm-Message-State: AOAM533KsQkwlMdYG9aUUDAEp3f8jTXY5YGGisSsWubdfRTHzJ5/w9yd zukGGyFLSwb6M3CR2erQXzdzjmhI+u1kzZNL9eQuBU9deOI= X-Google-Smtp-Source: ABdhPJySRzliOAHfQNbH/VU17PQDfwZ7tqKq9xSyUWwcJEb3enfoBheKQehqhSkPWbhFQa8YfY8iPJfpJ+CCn3E2PGA= X-Received: by 2002:a9d:1ea9:: with SMTP id n38mr5682959otn.233.1621367822605; Tue, 18 May 2021 12:57:02 -0700 (PDT) MIME-Version: 1.0 References: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> <532D1413-52FF-4403-A20B-BBDB51163C85@trowski.com> <9c83ba12-79e1-4fc6-9a75-7a6b04965f03@www.fastmail.com> In-Reply-To: <9c83ba12-79e1-4fc6-9a75-7a6b04965f03@www.fastmail.com> Date: Tue, 18 May 2021 20:56:50 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000001de16505c2a01dad" Subject: Re: [PHP-DEV] [RFC] Partial function application From: davidgebler@gmail.com (David Gebler) --0000000000001de16505c2a01dad Content-Type: text/plain; charset="UTF-8" On Tue, May 18, 2021 at 2:45 PM Larry Garfield wrote: > User-space functions have always accepted more arguments than they're > defined with. They just get dropped off the end silently, unless you use > func_get_args() or variadics. While I know not everyone likes that > "feature", it means that extra trailing ? "arguments" don't feel weird to > me. They just get dropped off the end and we move on with life. At least > that's how I conceptualize them. > This is my question about the partials feature, though; does the implementation have potential to reasonably be confusing? if it's essentially a convenient way of creating a closure, why would extra arguments passed in the closure call be passed to the wrapped function, rather than discarded? 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); But correct me if I'm wrong, isn't the latter what the RFC effectively proposes? > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --0000000000001de16505c2a01dad--