Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108132 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82644 invoked from network); 14 Jan 2020 23:45:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Jan 2020 23:45:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BE08518053B for ; Tue, 14 Jan 2020 13:52:17 -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,HTML_MESSAGE, 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-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.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 ; Tue, 14 Jan 2020 13:52:17 -0800 (PST) Received: by mail-lf1-f53.google.com with SMTP id n25so11081244lfl.0 for ; Tue, 14 Jan 2020 13:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EhuXhMGMZONjSPEB93tRudFFym013UZ1KlrxWjtJgbs=; b=LP8sBswNI9KCEy5lXNaEraaES6SCvldDJ7IxDBObNecyURoN5M+qYSx66RC4ZhypS8 yUGXFrc4UhLNY3KinBO3KzAoL4eVaodC22Dsu/2PDpppBnrXujwvJmKE/2XOznweiRav SM0UDpf3HuBnxl/Y5KxIXQswUoztYAmOIyLci8jhH1nseX40G2u3kOVwE1amX0Op38lC PkYHNTrslDKCK1l3BcZ2bTlRT97HTO3sMQh7oHC6gUbSLVYPqAO69sPlK+INjjpKtoHq /+1fSd5fOFG2amxinR8rkm6sIwyVP01Cp0H+loXKPG0C+10NjExwM8GE1PRV9uBXRMUN iqAQ== 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:to:cc; bh=EhuXhMGMZONjSPEB93tRudFFym013UZ1KlrxWjtJgbs=; b=GcRFn3lrSvWLdCl/+hDH9vJDRk2nfvV3ZpHUSN1ECJl0dFz4S3C5xYFzisgbGZPFQK FWoTYG3GRMbnByd/ZKfHnSj86lsFTly1BmL8TbMJ1bHRpHW/Bga806v32qJesUtsYUHW 0wg8tsT9dlTdchKJs4UVu5L4chFj/SMkEsEUgZZm7xELcO6zOAyX9YDl+Hv/B/HrArJf TPIZzWtnbpJ/AVDK80kTWVj3xpXzoqG5ekdzPdy8HF5rw807mGXfaGHSPg7ymoO/A+6d 974B1FxOBGeMK/6kXDGq+MNazu4+KxCBsCjjeQjukWgYA2c6V1xOQ8ZbUiRhts8x0Agk jxfA== X-Gm-Message-State: APjAAAW97+5FdrZVtaxaGtfG+8s4BvmzkttHc3tP4lW5qQgnLhTo0b+B 9NbTVHIjIzej/V7BoxBfLF9Pq73CIqH/mbeomj0= X-Google-Smtp-Source: APXvYqyr45jazzhaBpcaFd7BQsxVl1pyqU7JZKm0CWE7yLjgEOuZFQRVaehUkc7kBDUlznaY1+KeeSaZnO4H7AHYZA0= X-Received: by 2002:a19:4b87:: with SMTP id y129mr2984319lfa.32.1579038734184; Tue, 14 Jan 2020 13:52:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 14 Jan 2020 22:51:58 +0100 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000d674cb059c209a72" Subject: Re: [PHP-DEV] Re: [RFC] "use global functions/consts" statement From: nikita.ppv@gmail.com (Nikita Popov) --000000000000d674cb059c209a72 Content-Type: text/plain; charset="UTF-8" On Tue, Jan 14, 2020 at 7:27 PM tyson andre wrote: > > This RFC proposes to support an opt-in "use global functions/consts;" > statement > > to disable PHP's check for the function/const in the current namespace > before falling back to the global namespace. > > > > https://wiki.php.net/rfc/use_global_elements > > > > > > Earlier discussion can be found in the 'Opt-in "use function *;" for > skipping check for > > function/const in alternate namespace' email thread, which can be seen at > https://externals.io/message/107877 > >Let me know if you have any comments on the RFC > > I plan to update the wiki and start the voting phase tomorrow with the > voting structure mentioned in https://wiki.php.net/rfc/use_global_elements > Alternatives/Arguments > > mentioned in this thread have had summaries added in the discussion section. > Hi Tyson, I don't think it's a good idea to resolve the question of "use global functions" vs "declare" as a subsidiary vote. At least in my mind, those two options are significantly different, and this choice would affect both my overall opinion of the proposal and also the answer I would give on some of the other voted question. The RFC already outlines a number of reasons why it is preferable to implement this as a declare directive, so please excuse my reiterating some points here :) First and foremost, if we ever implement https://wiki.php.net/rfc/namespace_scoped_declares or some similar way of specifying declares on the package level, and I think it's pretty likely that we're going to do this in one form or another, then we're very much going to regret not making this a declare. Disabling the namespace fallback, just like the use of strict types, is something you will usually want to do for an entire library/project, not just for individual files. Going for something like "use global functions" preemptively precludes this for no good reason. Second, I think phrasing the semantics in terms of a change to name resolution behavior (which the declare does) is clearer than phrasing it as "import all functions/consts in the global namespace". That's not really what this this feature is doing on a technical level, and this phrasing is what results in questions regarding the behavior for various conditions regarding symbol overlaps etc. For example, with the declare, I don't think that it should be an error to make a function declaration inside a namespace -- that's still entirely well defined, and I think a legitimate use-case (a project that is disabling namespace fallback everywhere, will likely want to do that for files declaring functions as well, as a matter of consistency.) Third, I'm not sure it makes sense to separate this functionality for functions and for constants. I can't really imagine a situation where you would want to, say, use namespaced constants but global functions. I can see why you went with this split when using the "use" syntax (as we already have "use function" and "use const" both), but with a declare approach, I would suggest to combine both. Functions and constants live in different symbol spaces, but their name resolution behavior is the same. Finally, if you do want to go with the "use" syntax, "functions" and "consts" should not be made reserved keywords. There is no technical need for these to be true keywords, so we can avoid an unnecessary BC break here. Regards, Nikita --000000000000d674cb059c209a72--