Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:107894
Return-Path: <rowan.collins@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 89061 invoked from network); 30 Nov 2019 23:35:55 -0000
Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12)
  by pb1.pair.com with SMTP; 30 Nov 2019 23:35:55 -0000
Received: from php-smtp3.php.net (localhost [127.0.0.1])
	by php-smtp3.php.net (Postfix) with ESMTP id 648EB2D1FC9
	for <internals@lists.php.net>; Sat, 30 Nov 2019 13:31:40 -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-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332])
	(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 <internals@lists.php.net>; Sat, 30 Nov 2019 13:31:39 -0800 (PST)
Received: by mail-wm1-x332.google.com with SMTP id a131so13191389wme.5
        for <internals@lists.php.net>; Sat, 30 Nov 2019 13:31:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:user-agent:in-reply-to:references:mime-version
         :content-transfer-encoding:subject:to:from:message-id;
        bh=dA+8xteBrQb0Jh4vxd0YgINoW0qw7k25X0Gajq+lu0s=;
        b=GYHn6qrKIAn37Ih270LXdOJi6d0z8x5i9H3m7/9GE0od50BPb17spMv5h4R6eDEc+g
         nImwISV2V+MFAGHVx4RWHaw/G1dOcuxtZPUykb0lxjwA601XCxPafGEmJGjkb5iVmFQ1
         5DmkSVHc3EkZj729f9ZCBNxXmrZFq2PCa6XQuOtKtgH5YfBAO/99JoJpN7i70G+YDvGX
         Xz0k9JZzyykJ8BmRV8xND+sZSkEJJMLHLRmgjEv7u9YwCEC2SrrxPGM3SAPHu7EMskRT
         xYW1snzlJEkHWh1Stzp+GR7pfN6p083kZtFR2vLxeIOJ4iNnSSxtUnkTt86CdZbDXFzD
         zfDg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:user-agent:in-reply-to:references
         :mime-version:content-transfer-encoding:subject:to:from:message-id;
        bh=dA+8xteBrQb0Jh4vxd0YgINoW0qw7k25X0Gajq+lu0s=;
        b=Q8utypn1AcE+Idqm2KyzYIjp0p27cFM4/x12LY2jiVQJn7ZJvllB+2GfyI1R4rV9b7
         bKD/NYrL0XLXfrcU6DyJ5tvimKp76x+3yhgsseneKvlBA2HC9+GUG5i/+9Sawi6vpsT0
         Ti0KWo7akrSC415Be/zkdTlnzou9+LzvSu3y3Jc3TdeQHpMknkbrAv4sWYvMKXFZagAm
         r/hfYJ1oN4c2GCSwcQABI8UgbD7T4baXlOKHsiLjclHZ1Xyv/k3uqKfU0QSfperFxHDY
         a7UxlQvJy0dUCFhlbg0rmCsIUoLj3s/LXLT6P1D8qdVpGMRV/loR/wXwV42PiLaTLH7/
         YY/Q==
X-Gm-Message-State: APjAAAVbbTfUG8P5eIG2H7tYd2iQeypfR+S5EBZrVYp4IGL1rCR+6MYx
	gbR6w29o9Lfmi0vb/tf1/TZQ0jsV
X-Google-Smtp-Source: APXvYqx6H0j6Hmv07lIFhhgxapI7nI3FoOOr7mhCtpsZ/UcdAliPG+ev7L2PukrvbKEaEZt1/Xzq7g==
X-Received: by 2002:a05:600c:2301:: with SMTP id 1mr21749417wmo.143.1575149497791;
        Sat, 30 Nov 2019 13:31:37 -0800 (PST)
Received: from [10.135.105.183] (92.40.172.150.threembb.co.uk. [92.40.172.150])
        by smtp.gmail.com with ESMTPSA id k4sm19058779wmk.26.2019.11.30.13.31.36
        for <internals@lists.php.net>
        (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
        Sat, 30 Nov 2019 13:31:37 -0800 (PST)
Date: Sat, 30 Nov 2019 21:29:32 +0000
User-Agent: K-9 Mail for Android
In-Reply-To: <B4BE54F5-C7B2-42EF-BB45-6D3F84088E7A@gmail.com>
References: <DM6PR07MB45536166C2939FF19F496893F9440@DM6PR07MB4553.namprd07.prod.outlook.com> <DM6PR07MB455353145E4BEF79BF8C5A3EF9470@DM6PR07MB4553.namprd07.prod.outlook.com> <B4BE54F5-C7B2-42EF-BB45-6D3F84088E7A@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable
To: internals@lists.php.net
Message-ID: <05DFA426-3620-4A43-B48A-C6025F9EF24E@gmail.com>
X-Envelope-From: <rowan.collins@gmail.com>
Subject: Re: [PHP-DEV] Opt-in "use function *;" for skipping check for function/const in alternate namespace
From: rowan.collins@gmail.com (Rowan Tommins)

On 29 November 2019 19:48:37 GMT+00:00, Claude Pache <claude=2Epache@gmail=
=2Ecom> wrote:
>I don=E2=80=99t think it should be a declare() directive, because:
>
>* It changes incompatibly the meaning of valid (non-error-throwing)
>code=2E The current existing declare() directive,
>declare(strict_types=3D*), has the nice property that code that does not
>throw error in *both* modes does not change behaviour=2E
>
>* When you want to know the FQN of a random identifier, it is necessary
>and sufficient to look at the =E2=80=9Cnamespace=E2=80=9D and the =E2=80=
=9Cuse=E2=80=9D declarations=2E
>With `use function *`, that won=E2=80=99t change=2E With
>`declare(lookup_functions_somewhere)`, you have now to look at an
>additional place=2E


Hi Claude,

I understand both of these points, but both are subtly inaccurate=2E

1) strict_types is not the first or only declare directive=2E Declaring an=
 encoding fundamentally changes the meaning of a source file; probably it w=
ould be invalid in a different encoding, but errors are not the primary pur=
pose of the directive=2E Declaring a value of "ticks" actually changes the =
*runtime* behaviour of the code=2E The manual defines declare vaguely as "u=
sed to set execution directives", so it's not particularly clear to me that=
 changing namespace resolution would be outside of its purpose=2E

2) The existing fallback to global scope means that looking at the use sta=
tements of a file is not sufficient to resolve the ambiguity of an unprefix=
ed function name=2E Indeed, the same line of code can execute two different=
 functions within a running program if the namespaced function is defined a=
t the right time=2E

I'm generally not convinced that beginning the special directive with the =
word "use" automatically makes it easier to find or understand=2E Given som=
e code mentioning "strpos", you wouldn't be able to scan the list of use st=
atements for the word "strpos", you'd have to understand that there are two=
 modes of execution, and look for a line that switches between those modes=
=2E

I would expect that if it was worded as a use statement, coding standards =
would place it at the top of that list, so we're talking about the differen=
ce between:

declare(strict_types=3D1);
namespace Foo;
use global functions;
=2E=2E=2E

and

declare(strict_types=3D1);
declare(global_functions=3D1);
namespace Foo;
=2E=2E=2E


Regards,

--=20
Rowan Tommins
[IMSoP]