Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114470 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12718 invoked from network); 13 May 2021 20:37:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 May 2021 20:37:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 59796180511 for ; Thu, 13 May 2021 13:45:38 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, 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-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 ; Thu, 13 May 2021 13:45:37 -0700 (PDT) Received: by mail-yb1-f181.google.com with SMTP id i204so4219925yba.4 for ; Thu, 13 May 2021 13:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=6uPkVnyWPq/avYCm/UhEAkjoeWKn8/6UO29NrxpH3o4=; b=RUWWl43d20DQ8wWXa4btWFLEXeYF8KYAFBxKANbSJmaxZmWrTAW1eGTBK0qfnHOEQ1 enUgwELb8+sPcWJ4jJDbUzyL2bPDK65l91XOM9V6UIPv0DI6kYni3XjKh3Pup1L1Dyf7 45R4zYdYFG9PUvg8nn++hiSXNlA38NIiFDlF0= 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:cc; bh=6uPkVnyWPq/avYCm/UhEAkjoeWKn8/6UO29NrxpH3o4=; b=oGFNP0ZdtkZdR1XbW4FjuOqcbluDZ10k1hTicGIxtnEdy7GX85omC8ds1a9O+6HdPk 23MdoQPFMojm+MriQ0SbITphbkcVcKyQ8uzOV9mjfB7p6xe450nziHbe0ieVvTUKgSUN EFGVsaK7ks/vcgvmYELqX8tLbT7nJFUA/kwcHtZJE87d+rhDInxlk+0ncd6KQWNsTRNp Ds34Yz33pFjQgDUxg/TVDmOcdScfBl76QxTWXzduXASZ0SSgXWekAIYjS5yCILsVZxEH auVwd25Cj1gUyWrtesGk9ZC0szaB0vIHYZllgN900D3LaEX5m54pyG0JnhqiwIiBnncE 7UyA== X-Gm-Message-State: AOAM530/Uc1iW8zg6XT++jxfGUpLY/xwIcDc9cfnZAsKAgXD+UPMiVOG BtxOAFqjKyCPinxfVU8YsTKYKplQgpBz8aMATIpY1K7SaeNqsA== X-Google-Smtp-Source: ABdhPJwcvoovpmTIyGu1oc9UfcciuMeOPpMc93QJs/7PJN+tEWcmeIgVFEYyiDQrQYHE2qGPuaYWNv3MFiTUtOoJLy4= X-Received: by 2002:a25:2342:: with SMTP id j63mr3788654ybj.85.1620938736971; Thu, 13 May 2021 13:45:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Thu, 13 May 2021 14:45:26 -0600 Message-ID: Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Partial function application From: internals@lists.php.net ("Levi Morrison via internals") On Thu, May 13, 2021 at 2:31 PM Sara Golemon wrote: > > On Thu, May 13, 2021 at 2:31 PM Andreas Hennings > wrote: > > > 1. Serializing: > > But outside of the above cases it should be technically possible, or not? > > > > > I suspect that the limitations you cite make any kind of general > serializing both unreliable and impractical. I wouldn't plan on meaningful > serialization. > > > > 2. var_export() > > > > > Same as above, really. > > > 3. Parameter switching > > > > Could we express the following as a partial function? > > > > static function ($a, $b) {return foo($b, $a);} > > > > E.g. as foo(?1, ?0) ? > > > > > Using named parameter we can: > > foo(b: ?, a: ?); > > -Sara The current implementation doesn't support re-ordering anything. This feature has come up a few times. Personally, I don't think partials need to support this and every other potential feature; at some point a regular or short closure should be used. As a reminder, a `?` does not create a single argument in the closure's signature. All these `$partial`s are the same, and here I do not mean equivalent but literally the same: function f($x, $y) {} $partial = f(?); $partial = f(?, ?); $partial = f(?, ?, ?); $partial = f(?, ?, ?, ?); $partial = f(?, ?, ?, ?, ?);