Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125168 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id B1B801A00BD for ; Fri, 23 Aug 2024 19:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724442741; bh=sIE/5fYEMLjtv4/a62yt7k4D2eKPFFj/ZSUWJ1igQA4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=TTaD++nNENMx9HMoGUsLoKmvw9+rnoAboSALHMVdKtZM1PCJ4wrAC2goechaDxHFw ZD7YcOZdcBE7WokJMpdm6XYHpIe74f4qYQuT2mkKlhSSPD26E6pHSXGf1QElt9rnjV gxn7wtIUNNzX0nrbQ3o+dkU7vuOnMDxdHRMwql+331OpQz+Vr/WKn3g+Zi5nPJ8HOo IxKtf9iB52+6J5x9qEaQDmxyG7cpjfnFHPTc8rCNnJUfMOB+4leG/rPafU63ZoVUXT vvnNnvEolMSUsFvshgRWWJIbBg6hcYZWmlSjucnFWJ8Aw/ykzz66tUyLnKsJt987Oy z3C4mEGXjSzFQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4C8A2180EC1 for ; Fri, 23 Aug 2024 19:52:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Aug 2024 19:52:17 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 7FF141151AB2 for ; Fri, 23 Aug 2024 15:50:26 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-03.internal (MEProxy); Fri, 23 Aug 2024 15:50:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1724442626; x=1724529026; bh=sIE/5fYEML jtv4/a62yt7k4D2eKPFFj/ZSUWJ1igQA4=; b=DX1+Co0yIpLyIjjot5V63whmtg XAuJQyKV8R233BOxrc6uMqC8Rb78JE3wFCCc5CSz7t0WxlV9SfVPBQN9sE4kf2FZ XwtSmm+1AiUCg1fkIfv+1ws7BZRlwMGIHdNokp9yu8dkhH5YOu0NbuRLqcKI7Yed +8vxGbYn07E+/TSaSyXl0mSKEANlPjATvnAss1JxYLrnIKDTujGnSrtj143Qa+2Y MoXZPayhZJtbnlayK1e6JYndeQPsieCS8ERK7S85Ck7BlopyiX4OW3iJOaaRZTk/ vQKszkv93QDAAwFkNUhC+8WO8QFtH25bL4Ld9R3BN5VSNXw+P+OGng2j13Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1724442626; x=1724529026; bh=sIE/5fYEMLjtv4/a62yt7k4D2eKP FFj/ZSUWJ1igQA4=; b=WJik+dwoBux7FyckocDAWO1n0SuVLj7CnDoJO2LuZOUW txCmy5lJ6Uo8VCBwynJFxXSZdF5EqwyAcnxHRCsDiC69qGNoJ/rHqQetuEi9ciVB BZKIOMEtrIuYOH0Y0I2HieQ+qFHCs/FmId7TIvaowIo8bOocJAKT6Okqw9/XF1cm 2cMe8yxQDKS1RytZCfuE7dgChBOgSrRsPbiWubgtVovFnuC4r+4aQGgCC2G60ueV BmcLB/w2kgKj+o5KegyX1dI2Sc1WCEkskBwvRNbOk0bOpM75v02l1EfTMki/hEE4 5KnEhbwB39azaXLv0BBVUvETsR6FUgzw9VsOKBTJxg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvvddgudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdf uceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnheptdeuje dttefhueelhfdtleeiudetlefftdduleehffegtdeihefhleeijefgveegnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlh gvugdrtghouggvshdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhr tghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3F34D780065; Fri, 23 Aug 2024 15:50:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 23 Aug 2024 21:50:05 +0200 To: internals@lists.php.net Message-ID: <8087d6be-516c-489f-88c6-1376241e1301@app.fastmail.com> In-Reply-To: <977227E3-8793-4FB1-B572-B75D27C06ED5@rwec.co.uk> References: <21D6F160-5EAE-44FA-907B-E1DAAC1B8D75@rwec.co.uk> <53BD062A-4D7F-4E5D-852E-6D27641213A8@koalephant.com> <7607FD64-5572-466E-9866-63C2536B2A09@koalephant.com> <0d269a38-28fe-494c-a903-50022e09f27b@app.fastmail.com> <63DAE337-B117-4380-8735-186DC30FE0B7@rwec.co.uk> <977227E3-8793-4FB1-B572-B75D27C06ED5@rwec.co.uk> Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) Content-Type: multipart/alternative; boundary=001d4c0f6d2b4d3fb54bb7e06379d24e From: rob@bottled.codes ("Rob Landers") --001d4c0f6d2b4d3fb54bb7e06379d24e Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 23, 2024, at 21:41, Rowan Tommins [IMSoP] wrote: >=20 >=20 > On 23 August 2024 18:32:41 BST, Ilija Tovilo = wrote: > >IMO, 1. is too drastic. As people have mentioned, there are tools to > >automate disambiguation. But unless we gain some other benefit from > >dropping the lookup entirely, why do it? >=20 > I can think of a few disadvantages of "global first": >=20 > - Fewer code bases will be affected, but working out which ones is har= der. The easiest migration will probably be to make sure all calls to na= mespaced functions are fully qualified, as though it was "global only". > - Even after the initial migration, users will have to watch out for n= ew conflicting global functions. Again, this can be avoided by just pret= ending it's "global only".=20 > - The engine won't be able to optimise calls where the name exists loc= ally but not globally, because a userland global function could be defin= ed at any time. > - Unlike with the current way around, there's unlikely to be a use cas= e for shadowing a namespaced name with a global one; it will just be a g= otcha that trips people up occasionally. >=20 > None of these seem like showstoppers to me, but since we can so easily= go one step further to "global only", and avoid them, why wouldn't we?=20 >=20 > Your answer to that seems to be that you think "global only" is a bigg= er BC break, but I wonder how much difference it really makes. As in, ho= w many codebases are using unqualified calls to reference a namespaced f= unction, but *not* shadowing a global name? I can think of more than one one-off script where I have written somethi= ng like this: namespace blah; function read_and_process_file(): array { } function do_something(array $file): void { } $file =3D read_and_process_file(); var_dump($file); // die(); // debug do_something($file); If it were global only, then how would I call those files? namespace\rea= d_and_process_file()? That seems worse ergonomics and not better, for very little gain. >=20 > Regards, > Rowan Tommins > [IMSoP] >=20 =E2=80=94 Rob --001d4c0f6d2b4d3fb54bb7e06379d24e Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Fri, Aug 23,= 2024, at 21:41, Rowan Tommins [IMSoP] wrote:


On 23 Aug= ust 2024 18:32:41 BST, Ilija Tovilo <tovilo.ilija@gmail.com> wrote:
>IMO, 1= . is too drastic. As people have mentioned, there are tools to
=
>automate disambiguation. But unless we gain some other benefit = from
>dropping the lookup entirely, why do it?

I can think of a few disadvantages of "global first= ":

- Fewer code bases will be affected, but= working out which ones is harder. The easiest migration will probably b= e to make sure all calls to namespaced functions are fully qualified, as= though it was "global only".
- Even after the initial mig= ration, users will have to watch out for new conflicting global function= s. Again, this can be avoided by just pretending it's "global only".&nbs= p;
- The engine won't be able to optimise calls where the = name exists locally but not globally, because a userland global function= could be defined at any time.
- Unlike with the current w= ay around, there's unlikely to be a use case for shadowing a namespaced = name with a global one; it will just be a gotcha that trips people up oc= casionally.

None of these seem like showsto= ppers to me, but since we can so easily go one step further to "global o= nly", and avoid them, why wouldn't we? 

Your answer to that seems to be that you think "global only" is a bigg= er BC break, but I wonder how much difference it really makes. As in, ho= w many codebases are using unqualified calls to reference a namespaced f= unction, but *not* shadowing a global name?
<= br>
I can think of more than one one-off script where I have w= ritten something like this:

namespace blah;=

function read_and_process_file(): array {<= br>
}

function do_something(array= $file): void { }

$file =3D read_and_process_fi= le();
var_dump($file);
// die(); // debug
do_something($file);

If it were= global only, then how would I call those files? namespace\read_and_proc= ess_file()?

That seems worse ergonomics and= not better, for very little gain.



Regards= ,
Rowan Tommins
[IMSoP]


=E2=80=94 Rob
--001d4c0f6d2b4d3fb54bb7e06379d24e--