Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112212 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63959 invoked from network); 8 Nov 2020 18:21:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Nov 2020 18:21:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E12F1804C6 for ; Sun, 8 Nov 2020 09:42:57 -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=-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-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 ; Sun, 8 Nov 2020 09:42:56 -0800 (PST) Received: by mail-wr1-f41.google.com with SMTP id l1so1974364wrb.9 for ; Sun, 08 Nov 2020 09:42:56 -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=LcRsEAAwll3y0UCNvozM6fhPXNZ7ioejtlwjd6lJEBo=; b=aW9D3g+Bej7jgVK+Xvn1+EGkw7lg/cVQrwqxpBjme7N147XFM+XhAjR0bMSN9GYOGK pElAHIugz4RCerKwTlqiFGIjZiVKixRIogfyvwqC0fdgObvJV3l5d6ujwbL8j3DrSE66 URUr6eYe6cb9UPpiRsEru4LOtzSj4LgHjoaoa/bQqYHQX7Rw+nvHBRYu0c5FDCEuDGTB 10oSkwPUDhMhLKtS7a+m0XlFNmycUgd8r7HAKAGQvpIjoyVr0ZVx3eGLeQhqnSKKAmEI 320wljWp75FeG23ly6wDPYBXQ99lrMstwEuDonx9RCJDnAWTwbwqW5hb3FprpzEv5RvH gaOA== 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=LcRsEAAwll3y0UCNvozM6fhPXNZ7ioejtlwjd6lJEBo=; b=oovRvue3lUfSbxNu0ESVoqOxa1PJvoVCwO81r6wiv1l5aoziGFxoUVUpFEpppTcrsk 0Cn4jauOa9jZeiSmcrYkZELC1NX41UuL6dkZFC8X3xdFv6p3uBhfKMziR8fG8zSdmYm4 IhMrHB4qe5kynee8L+IZPwdlpEfdOnSewo5g+oukPtei2jqu9ZcF+b/rxr2EzL42wAUk EXp5VlYTEl437iYsoKwfRcNdGvFcLvoIZzfA2SzBdXbLTssD96KTEJU4kgEZr1C0WJy4 tKtLvC8ej1AbyNY6Ccj8OYTJ58ZaTsaz/y394XvLsQO+lOyVtYUF9nuDb0ww/z5fs8tU EAsg== X-Gm-Message-State: AOAM530EPgAXpRcFvXp0mzN0NIF3S/7NxZOdNiD+qKJkTlsiCEjmuxsY tXqOcxdEDgUFHHxkVHAaG6YzHcKFWTM= X-Google-Smtp-Source: ABdhPJwPNnL8cBpwjxy9Ef6zxPWOADOhwzaScS0aoMZQW3mKIkYJVZr1H35QQEQYjbBF8WHA/zsqXQ== X-Received: by 2002:a5d:4104:: with SMTP id l4mr12837246wrp.276.1604857374582; Sun, 08 Nov 2020 09:42:54 -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 l3sm11339879wmf.0.2020.11.08.09.42.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Nov 2020 09:42:53 -0800 (PST) To: internals@lists.php.net References: <57bb761c-48d1-41ab-9c91-d9ada8cfe26e@www.fastmail.com> Message-ID: <6fa936e4-6d12-4e3f-3a01-55242be18717@gmail.com> Date: Sun, 8 Nov 2020 17:42:53 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.1 MIME-Version: 1.0 In-Reply-To: <57bb761c-48d1-41ab-9c91-d9ada8cfe26e@www.fastmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Support for ::function syntax From: rowan.collins@gmail.com (Rowan Tommins) On 08/11/2020 02:12, Larry Garfield wrote: > There was some discussion earlier this year, although if memory serves it was in a thread whose name would not be helpful for searching. Here it is: https://externals.io/message/108459 Some of the key points (not an exhaustive summary): - Looking up a function's fully-qualified name would need to check at run-time for the function's existence, since there are two possibilities for any name that's not already fully-qualified ('foo' and 'current\namespace\foo'). This is different from ::class which (in most cases) resolves the expression to a name at compile-time based on current imports, and can resolve to a completely non-existent name. There are cases where it resolves at run-time [see https://wiki.php.net/rfc/class_name_literal_on_object] but none have the case of "valid name but no such class defined", which would need to be handled for functions. - There was some discussion about the usefulness of returning the name, or a callable object, or some way of providing both. Suggestions included adding two new syntaxes, ::function and ::closure; simplifying the creation of a callable object from a string; or returning an object from which the name could be retrieved. - Should (and could) the new syntax work with methods as well, e.g. Foo::bar::function and $foo->bar::function. If foo::function returns a string, these would logically need to return ['Fully\Qualified\Name\Of\Foo', 'bar'] and [$foo, 'bar'] respectively; if it (or a variant of it) returns a Closure, it would be the (optimized) equivalent of passing those to Closure::fromCallable. Regards, -- Rowan Tommins (né Collins) [IMSoP]