Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114477 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31603 invoked from network); 14 May 2021 23:01:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 May 2021 23:01:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 158AB1804CC for ; Fri, 14 May 2021 16:09:54 -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, 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-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.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 ; Fri, 14 May 2021 16:09:53 -0700 (PDT) Received: by mail-io1-f52.google.com with SMTP id n10so362408ion.8 for ; Fri, 14 May 2021 16:09:53 -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=ABhGzxSLC9Nk0PWehtKtc866oCVkM9/B5JS2onFoeAE=; b=UAuTaPvkwJgiVwCZfStA6+MLYr8wjCeh3Zzc4+Ea5E22Y4rRJAi39JRFoDDtBrXW88 DeB5QuQZNNC1lgJwk+iRUrO8WqD4caUGrGRsyQ1hWG1vsL8p2CgaWzxK0X6cu5ax+4OD qlHbu5CGPElT00hRsV+3UMHZKdCF8RsNmJayHCmSlffJTp051+i+vkWEsvq41Pcs99Lw q2iOP5MuoZ+o8yW+obXy0S/8gmIl+a4vz9gZEbhTseDe/j4JqTa7k7ZNPJz4Eu7Ol/B5 ixgs1ViHdH26q79f1fHlnc1T0bj0CcBkhuPoFoiUhRZU+lEE6pWChss1sfwJKLBpiiQT eZdg== 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=ABhGzxSLC9Nk0PWehtKtc866oCVkM9/B5JS2onFoeAE=; b=k1U0tLov1FEuQD9VtFQ4jStU3xM8OMIAf5yo9hE5DG46CX/SeqvY0Usad7EQYdesEO eNM1T14t36SAFijHOMO0Rj3fHwNzM30HJxuSV+sU6srWQaKOWfVPbqEVpcekw+NQXRK6 6gmJUEPnzBuvN1r4wDn/R8w7ygwyzLgHuOqw5Z5mBHSlnH7UUjqshG/+omYITfZPSOTW +iK7xqAHt37zwxpbYlyaQUY5xuMrBAsiaul0B3bHN1Zeiv/4SI81K1h17c/zcR43sfAM cmenO2ekygrNCfUwjssqReEL0hilB939rewD44MC+Myn9knEbomnVtdg3/HyD2mVJL3G weog== X-Gm-Message-State: AOAM5313UGjOizPLry4OKNA00OoRslAhQTNsyFD0CTk4/NuNixjQ/Y/R itAj2pGZpBKeuQTBeK58PxKKpGpVtzSxasH0mg== X-Google-Smtp-Source: ABdhPJzkRIm104J2bXW2CNimlfQHv7JUx2dBO+Dc7oYnG1uZK16C905sqbRfG1EbsDtJjMgb8cPe1Z+IgMUBLtB7ep4= X-Received: by 2002:a6b:d918:: with SMTP id r24mr36230891ioc.25.1621033792915; Fri, 14 May 2021 16:09:52 -0700 (PDT) MIME-Version: 1.0 References: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> In-Reply-To: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> Date: Fri, 14 May 2021 16:09:41 -0700 Message-ID: To: Aaron Piotrowski Cc: Mark Randall , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Partial function application From: paul.crovella@gmail.com (Paul Crovella) On Fri, May 14, 2021 at 2:49 PM Aaron Piotrowski wrote: > > Consider `function foo(int $x, int $y, int $z) {}` with a partial defined as `$partial = foo(?, 42)`. > > If the partial is called as `$partial(73, 8)`, should 8 be forwarded to `$z` or should the call error as providing too few arguments? The 8 passes along to $z. There is no error, all required arguments have been provided. > Or perhaps should the partial declaration should error, as it should have been `foo(?, 42, ?)` or `foo(?, 42, ...?) so the partial provided all required arguments to foo. I think this highlights where the misunderstanding of this feature is. Partial application is about binding arguments. ? isn't an argument, it's an argument placeholder. It does two things: signals to create a closure wrapping the function rather than calling it immediately, and holds a position in the argument list so that an argument further to the right can be fixed (bound) at that time. Arguments are bound; argument placeholders are not, they exist only for convenience. The syntax `foo(?, 42)` doesn't call foo, let alone provide any arguments to it, it simply creates a closure that'll pass along 42 at the appropriate argument position along with whatever else it's provided with. Requiring additional trailing argument placeholders or adding an additional token `...?` unnecessarily complicates things, burdens the user, and only serves to further promote misunderstanding. > > Cheers, > Aaron Piotrowski > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >