Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108094 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60962 invoked from network); 10 Jan 2020 23:38:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jan 2020 23:38:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 489F61804A8 for ; Fri, 10 Jan 2020 13:44:36 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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, 10 Jan 2020 13:44:35 -0800 (PST) Received: by mail-wr1-f53.google.com with SMTP id z3so3187529wru.3 for ; Fri, 10 Jan 2020 13:44:35 -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=v4mGMzeaLBwRtEYXYiRSkf1GUSROoAURoSnNvG/M4h4=; b=Z6P/wcxnR7ZUGf+tLVDI6W+xQv4X8yV0nOS880eYAqyD5PJjRItav7c5zkA3Tc8ePn JwEHRVOmB3gecn5na+kmQ/U0TPJK3hxYqJvrj1Nvq2ddEwHpM0ATKHDfocW31hE3LCY2 IrcV2cbBLf+2LJoF1dxb9GW+Eml4VY6aaLk6qe/uZhfVIibdOsYK9qUMwhNCdzSibEAf rtlOCNp5IRA31Zf03m/Yi4k+p1/4l10tOkFOkyCCVaZu4WycwXm9GT5psghcckU1cJhD 4MFS0irp4n8cDVm5xGbKIxUdp6JROcXIQICudXsVTivQpgvo3HezCf6kQkOwJeqIeDUK KAMg== 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=v4mGMzeaLBwRtEYXYiRSkf1GUSROoAURoSnNvG/M4h4=; b=jShSaxJ6VNoUrppvuf0ECS5GBXJu2peVt7VcIL3h5rI1b90gclWTlqK9ZXJNby108E gJDJKNCbwX82SodjPEyHFntTCwrnfZyCaSS6+9bRu4eXlTqEbfVwSa4y5F8BrCE/+0XO GC92zf8pkOztrIH8Jz8sY3p6iAYpW1f9vdGBwPcYm6YgPZ64oBGx2fUNgyW3aKTQUn3U /9kIuh0N2pX1VN+4hg6J5J6oizHLZXgvJjh5lVit1AOzaQ2y33CXSKxDn2yR+DjEJL0d 7ZULFljjvMcrxiz3RL0fuqMg/CwdLmBIfXJVA/FB1xXPXYE4ZU0Os3CD26I+MifdGajX cjTA== X-Gm-Message-State: APjAAAWkJxUkEcOV/QxQaVmZVgpQaLjrOEe8M14ur85ZGB8oAI4RXdMm MQBpIU8NOrUsm6MnyP5ZglsQ29Yt X-Google-Smtp-Source: APXvYqztYmGPxbN3o3U/MB8ki2Y31VI9HD9t/6S+Tt7SwT/dhnkdVyLF2MBukKQm2FOocJ9rrolxrw== X-Received: by 2002:adf:eb09:: with SMTP id s9mr5679158wrn.61.1578692672484; Fri, 10 Jan 2020 13:44:32 -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 h2sm3862285wrt.45.2020.01.10.13.44.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2020 13:44:31 -0800 (PST) To: internals@lists.php.net References: <13CC52AA-7690-42C6-89B7-B8FA4166BF38@newclarity.net> <57c08851-e6e2-c0bd-76e1-f7a0388d64b4@ralphschindler.com> <60610660-2E38-47BD-A998-1E226CEB3701@newclarity.net> <032B5597-6CB6-4F5E-BDDC-8A508C3FCE93@newclarity.net> <69403AE8-F8F6-4221-B31F-41B1E982A2C5@newclarity.net> Message-ID: Date: Fri, 10 Jan 2020 21:44:30 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 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] Allow ::class on objects From: rowan.collins@gmail.com (Rowan Tommins) On 10/01/2020 17:29, Larry Garfield wrote: > But having some kind of working way to reference a function that doesn't involve concatenating a string onto a namespace constant would be*super* nice. Whether it's called ::func or ::nameof I don't much care. > > Viz, replace this: > > $func = __NAMESPACE__ . '\myfunc`'; > > With this: > > use My\Code\myfunc; > > $func = myfunc::nameof; Note that the above example should be: use function My\Code\myfunc; $func = myfunc::nameof; That's important, because we couldn't actually have one operator that resolved both types, either at compile time or run time. For instance, this is valid code: namespace Whatever; use Bar\Baz as foo; use function Something\other as foo; echo foo::class; // "Bar\Baz" foo(); // runs Something\other(), not Bar\Baz() A ::func operator would also need to deal with everybody's favourite name resolution: the dynamic fallback to global functions. In other words, this... namespace Foo; echo strlen::func; ...would need to print "Foo\strlen" if it was defined, and "strlen" if not. That would then make it odd if a completely undefined function didn't error, so I don't think it could match the current behaviour of ::class. Regards, -- Rowan Tommins (né Collins) [IMSoP]