Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108313 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83868 invoked from network); 29 Jan 2020 11:47:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jan 2020 11:47:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15F8818053D for ; Wed, 29 Jan 2020 01:57:47 -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-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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, 29 Jan 2020 01:57:46 -0800 (PST) Received: by mail-io1-f54.google.com with SMTP id x1so17869031iop.7 for ; Wed, 29 Jan 2020 01:57:46 -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; bh=7sdV3j/1wd1qSdQXmPe+4323xmbYTsQa8iSOczqKjrU=; b=k1MG42AMYBC7uwM9pvz581uWr3VXq7XXZti72wbvlBsAaC1cYZd3iLM4HelFIyr72I HQLnt0iAtMo3BUfWHCc/Y1Xis0QmemruVLlmbrf6dx2vQRiM1PMtmiWxAasfVPNgRKdM OA9gSLcavgGPvmZB8VORUfZXOD+CZUGsLhrdSXo2gHDspn3I+M80EzpUiwmz1XPHgqlh auYg/ySCj7/JwNRz+Y2PtSKLE66mustjioOyTI89oSRD2Y/J3YZxV5M7WoPsyOSomq2q vYytjsix/pDuRBoaB8OOjiDrITxRdyoLWObtuDEzo6B7KiTCZrovQ9zxeJoEIWEQHK1R qNTg== 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; bh=7sdV3j/1wd1qSdQXmPe+4323xmbYTsQa8iSOczqKjrU=; b=geFXAucdluqzjdWr5MIujAyzVSOHZMIFpAdGDcny/AeR4X8gOhuGxGVLN6kf70Etm2 cKK9wCutmFeLnf9nAsVCZnm4mRuOHBbInGHBgOcDPHTzexF42NDd4HXnidQSXeajizIC kOCVaBqN0iHHAuHZlrEc9TJ467XO35APFnpnYWNVqQL9z70IToEq/YyEQ7TMs+ewVMXj ItXV9Dq4lOBviAWYjEAkEMFVTJ6azywp6cK6n/VSTTuED7d6XZyb6fZS/Ui2IJBxdEPU EXJ6f4Y/VYhdOtk3B8DMf4cS39zbippt0WOaYgDtXMNxOnYgIAUa/nSW2A5DDsq8H2Sg JRYQ== X-Gm-Message-State: APjAAAXsfiGkDjGv9kvDAJr0bQnfI2aVbghL4wDU1WvolbdHVK1/XmqW ar1Ocr2N8XbmqlD6EAHtLEJ2Hwh4k9IC/dh7jBEHXHog X-Google-Smtp-Source: APXvYqwZbuvmXPS3vWcDRSZuB+p7fzG9MadISdRzOglZWWEAVoK+NEPxZ5y9nmBih7uE67f/X6k+1MIaXnHkn1nhdSI= X-Received: by 2002:a6b:4906:: with SMTP id u6mr19751238iob.120.1580291865755; Wed, 29 Jan 2020 01:57:45 -0800 (PST) MIME-Version: 1.0 References: <2d50c8c0-cbd1-0a0e-4098-eb00facf86db@gmail.com> In-Reply-To: Date: Wed, 29 Jan 2020 09:57:34 +0000 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="0000000000004cc460059d445f5c" Subject: Re: [PHP-DEV] [RFC] "use global functions/consts" statement From: rowan.collins@gmail.com (Rowan Tommins) --0000000000004cc460059d445f5c Content-Type: text/plain; charset="UTF-8" On Wed, 29 Jan 2020 at 01:23, tyson andre wrote: > If a future language change changed the *default* resolution rules for > functions or constants, > I'd rather have future maintainers make the decision on whether to add a > 'fallback' to make migration > than on whether to remove the 'fallback' if it didn't make sense to > support it. > > We have different values and expectations on what's likely to happen in > the future of the language. > I think it's more that we have different understandings of what exists in the language *right now*. In my mind, strict_types has two modes, called 0 and 1; both have fully documented behaviour, and changing either one of them would be a breaking change. At the top of a file, I can specify which of those two modes I want the code to run in. As a convenience, if I don't specify, the code will run in mode 0 - but that doesn't have any implications for what mode 0 means. Similarly, if this RFC is merged, we will have two algorithms for resolving a function name in a namespace; let's call them mode A and mode B. * Mode A is "namespace first, fallback to global". It was first defined in PHP 5.3, and as far as I know hasn't changed since. We don't have to be speculate on how that mode works, we've been writing code in that mode for 10+ years. * Mode B is "global only", and is new in this RFC. In the same way I can specify the strict_types mode, I want to be able to specify at the top of a file whether it should run in mode A or mode B. If I don't specify, it makes sense to assume mode A, but that's just a convenience; it could theoretically give an error telling me to confirm which mode I want. Of course things might change in future: * Someone might add mode C, in which case I can select that for files where I want to use it. * The default mode might change from A to C. All my existing code is written to use mode A, so I want to make sure it continues to run in mode A until I've updated it. * We might deprecate and remove mode A, in which case I'll get log messages for the files where I've specified mode A, telling me to change my code to run in mode B or C. In all of those scenarios, it's an advantage to be able to declare mode A. In none of those scenarios do I get any advantage by specifying "use default mode". > > Can you provide an example of when you'd want to use 'default' instead of > > specifying the mode you've written the file to run in? > > The use cases are similar to the reasons why I'd want to use > strict_types=0. > strict_types=0 is rare in practice. > > 1. Explicitly writing in code that you have chosen on a setting for the > file > and decided not to use 'global'. > 2. Overriding the namespace default if > https://wiki.php.net/rfc/namespace_scoped_declares > gets accepted. > The reason I asked for specific examples is because every single scenario I've thought of so far, whether it's future changes to the language or namespace-scoped declares, would work better with an explicit mode setting, not a 'default' option. For instance, over-riding the namespace default sounds like a plausible use for 'default', but in practice, you wouldn't care which mode was the default for PHP; you would know that this particular file will only run correctly in mode A. So you would specify mode A at the top of the file, not 'default'. I have genuinely tried to come up with a situation where 'default' would be useful, and I have failed. Regards, -- Rowan Tommins [IMSoP] --0000000000004cc460059d445f5c--