Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108525 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15360 invoked from network); 13 Feb 2020 00:33:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 00:33:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 37E9D180538 for ; Wed, 12 Feb 2020 14:47:28 -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=-1.6 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, SUBJ_ALL_CAPS 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-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 ; Wed, 12 Feb 2020 14:47:27 -0800 (PST) Received: by mail-wm1-f41.google.com with SMTP id a5so4154111wmb.0 for ; Wed, 12 Feb 2020 14:47:27 -0800 (PST) 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=9mi6nAF5/cGMNjbqIMPmeH4HnpxL2UfNU1FRcDI3SKA=; b=GRFvXCHR6laOlHxMTmLvZz2EN55RzXF+IZ839Z86p4Kny7mCpNLyuHFdX4Y1VOdFcS RozyCKW50ZiDIcxcb6wSi0Omaa98KJuBSXx35BcsYu2lyVe4pYXWyEKtBKjRcLNWQ+NC X/I2Co2Hf+1zBY9FBxB6Nf4AOklTxNWelueVHl/oOevDur3El91uhtplfvPx1rIl0u78 0C1fgTkHq7qATQnjmVgv3M2A9hNEW2/e+CjaW+ryxy+5Cu6MVDvEXlYv0rfedqfkAJXz 702D4u8ngLfEjWvEznzW+Us4vUSHiWUottYKmrPnypwI85nurJJ+LPxbdioLvbCnFHSX EbFA== 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=9mi6nAF5/cGMNjbqIMPmeH4HnpxL2UfNU1FRcDI3SKA=; b=VhGReGOAWp9aUQB9Vm9SSOnA/NktZU8IEdi8HqosEYrv9tr6xxw3V8SyTIyd/apeZC q8EUez2uzFSx0U1entlYG4aIp5O3jQIUwwvenuV6HHdRSfeU3WqH11lyrI7LwzlHRZ4f aFOWT2iEdrkIeS3KhLCWcSCp+kZz8tKaeAjPN5GCJtaOiyfC9tXX36F7BV2X7SARC6/O 8fM9xGTxFMMcLpYnkZGQBLd8AscxevCrB9EQ7FwNeLGkeispx3vFDONtKkfv/MUxwQgA RoyN5RcsCIac43XS5quva9vaCeVkQ7HagGFBYmX8JgSK+r3IKX8L6QI8SLG5Lh2/ExNC dP9w== X-Gm-Message-State: APjAAAWCsEEkqWIGrPAtnr5c3Sg4lA7D9gammQAbU0+t5tLxnqzefp+i an1DT8qg9d7/jNjAeo59l1hxs2UT X-Google-Smtp-Source: APXvYqzud1u/mt6cD8tId6AqGbNzist6pdwHQIBslQOsQ9VmdLORqbrRmEKl6BZUAICzQ4QW5drhTQ== X-Received: by 2002:a1c:9a13:: with SMTP id c19mr1336131wme.134.1581547646186; Wed, 12 Feb 2020 14:47:26 -0800 (PST) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id i4sm332236wmd.23.2020.02.12.14.47.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Feb 2020 14:47:25 -0800 (PST) To: internals@lists.php.net References: Message-ID: Date: Wed, 12 Feb 2020 22:47:24 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] From: rowan.collins@gmail.com (Rowan Tommins) On 12/02/2020 03:58, Mike Schinkel wrote: > Returning a_closure_ instead of a string would be providing a feature we_already_ have instead of one we do_not_ have. Not really, because you still need a way to get the fully-qualified name of the function. This is not valid: namespace MyVendor\Something\Foo; function bar() {} \Closure::fromCallable('bar'); # Error: tries to resolve function '\bar' So if we had ::function which returned the name, and ::callable that returned a closure, the following would be equivalent: namespace MyVendor\Something\Foo; function bar() {} \Closure::fromCallable('MyVendor\Something\Foo\bar'); \Closure::fromCallable(bar::function); bar::callable; One combination would be ::function returning a string, and $() accepting one, which would give: $(bar::function) In practice, that would almost certainly be optimised into one instruction, so the main advantage would be consistency, unless there are use cases where a string rather than "any callable" is actually required. > Or today just use fn() => myfunc(). That's not quite the same either: at the very least, you need to define it as fn(...$args) => myfunc(...$args) to pass through the parameters. But Closure::callable is able to copy the signature of the original function, including type information [1], so our hypothetical ::callable could do the same. [1] https://3v4l.org/XBOmJ Regards, -- Rowan Tommins (né Collins) [IMSoP]