Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107888 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46437 invoked from network); 28 Nov 2019 23:29:02 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 28 Nov 2019 23:29:02 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 7626C2D2000 for ; Thu, 28 Nov 2019 13:24:17 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 28 Nov 2019 13:24:16 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id l17so12249854wmh.0 for ; Thu, 28 Nov 2019 13:24:16 -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=oOsORtTS3LxnhVpe11FtQ1OgY+MVvGrWbgLaMHiONYI=; b=Ld042X+oRllGozQ/mA4N/80Xq7gwKe2pz7CrAkJEF6rTRzve5rrf4FwtEta55zcjJ1 5nzrdnelHm6mrihTqfxXPB5m4FEs04VXSa2UhPihwdG5g2YLoDXfHu4zQ8LOyoGMkQMC NDcovQ8b/r+elmaW1RWVT9U9l7vR3AbmUQHIV06g6TAIwNIMlt50rfJvfu9JoiV3NVJV DoZXAAlrX6JkhaFESHN/6rctetbqShbNxMuwtRKPv2eM9ls2SeC3uPBWb3jMRshtQHAs 11FgXSCze/Ol88rD8IqOIXjefBb79eOFbsF6W4pHr2p0qwhgU2DFUH3c5IlaecnxVf6V nmNA== 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=oOsORtTS3LxnhVpe11FtQ1OgY+MVvGrWbgLaMHiONYI=; b=KwjNl7O1YGxDoBk+fXKzu7hyDq3LVcRMVSzaD4wL6BSqAEVAW107zvwp6NHs0E6OO/ TRJsuZTwGxupEoLAMC48nN5/YqMtuo1KQyT7FPzv9Njs4S3+EHNOX+oVH7jqoTa6lhjj K/hDRJN6Kg00Gb5zczJqrFT0KkH3qRMPT4rAOxAJ4eSHfKX7zBYptSSdTzg11HV9J4cr tzUqD5HGQLopRE2F8Xv8yYtMc5Q3LhUF4ZRrsPfxzChN0FhLhro1wVWk64CKUkeLFAgp rm2hFhdQAw5qV3Nj3Ev/H+USHf60H748Rb3myKqXJ1UoaJHK9byTkH/EtOFfsdAR3sSy ijTA== X-Gm-Message-State: APjAAAX3RzKszW7oT3OADqrUvvvwX8B3v71FgAvv8/AYzEkg/f64gbEF 3o+NL/A6yVPtYFizM6wp8RHk1hpi X-Google-Smtp-Source: APXvYqygG9ZEnzKLikgzQSwJRzEGQct+fKf6PRE8eRkjaODKgYE0J428Jl6g1lSXMCuEB5bZqXdMAA== X-Received: by 2002:a1c:7c0e:: with SMTP id x14mr11101556wmc.62.1574976254386; Thu, 28 Nov 2019 13:24:14 -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 e16sm11402834wme.35.2019.11.28.13.24.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Nov 2019 13:24:13 -0800 (PST) To: internals@lists.php.net References: Message-ID: Date: Thu, 28 Nov 2019 21:24:12 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.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 X-Envelope-From: Subject: Re: [PHP-DEV] Re: Opt-in "use function *;" for skipping check for function/const in alternate namespace From: rowan.collins@gmail.com (Rowan Tommins) On 28/11/2019 18:52, tyson andre wrote: >> An opt-in mechanism is certainly easier to migrate to, but it would be a >> shame if every PHP file in 10 years time included a line like this: >> >> use function *; // don't know what this does, >> but apparently it's good for performance ¯\_(ツ)_/¯ > I'm not sure what assumptions you're making about php in 10 years > (e.g. do you assume the other RFC will pass and this would become a no-op) My assumptions weren't particularly about the future of PHP, but about people's usage patterns. If nobody uses namespaced functions, then everyone will just turn on this option all the time, without ever needing to know what it does. The effect of adding it to 99% of PHP files would be nothing but a "magical" performance boost. > if someone were to fully qualify all function calls for a library for performance, > there'd be around 10 lines per file instead of 1 Only if they did it by adding use statements, rather than prefixing the function calls with backslashes. I'm confused why anyone would bother keeping a long list of use statements up to date, rather than just making "use leading backslashes on global functions" part of the project's coding style. I can see that adding a single statement to each file would be better than either, though. > My reasons for this syntax instead of that are: > > - This syntax can go in one block of code, instead of separated by dozens of lines: > > // dozens of lines of class uses, file comments, etc. > use function otherns\my_function; > use function *; > - There are no per-namespace declare() directives right now, for code with multiple namespace blocks I think it's more than just a different choice of syntax, it's a different way of looking at the feature: rather than a special namespace import, it's an option for how the language behaves. My thinking is that if unprefixed functions *always* referred to the global namespace, we wouldn't say "the global namespace is imported by default", we'd just describe the behaviour. Looked at from that perspective, it seems natural to say "in this file, I want the behaviour where unprefixed functions mean global by default"; and in future, maybe be able to say "in this entire module, I want that behaviour". A more cosmetic consideration is that the more generic the syntax looks, the more people will want it to work for other use cases. I can imagine "use function * works but use Foo\* doesn't" ending up on websites like PHPSadness. A more specific statement, like a declare, or "use global functions", is more obviously a one-off. Regards, -- Rowan Tommins (né Collins) [IMSoP]