Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125103 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 8D4421A00BD for ; Thu, 22 Aug 2024 23:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724368633; bh=kO58zNwVvfeNugkLVH9NH7yVGB+Os5N9A9ouVHf3dsQ=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=Uss9iZUfLMaA2iOFXty1wiBjnYy+4zJMsjV0VJ9VkDovf5iBf/xO0CyapmQZ1q+FQ 6JJvAn2XmjWT+8d6bZ+F4HDoG5MhmxWa+B/XTUghByOxKX+uVPEaCxGEfuS+oDuNyl 928FaTK5oVLFu7m98nzpPnsGXSlOxyhYBu0dkCzu1dD4cs2suswOxs7cQE9eGRTide r+aI2yZz1Y7aq1A72vFfBqp8e/IJ13ymmW5SBIo0r+UFqAEAhR/Tbof37S5DPBkTx5 OIu7wSJQLbw91VJCnSBb8z/FoyIMc3/31jqqeBDifTYlUOsU8F7fg+EHtUUYzpHINM wnZ1j9uj/qHXg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1D797180055 for ; Thu, 22 Aug 2024 23:17:13 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 22 Aug 2024 23:17:12 +0000 (UTC) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-690aabe2600so13456327b3.0 for ; Thu, 22 Aug 2024 16:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1724368521; x=1724973321; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=u73IhMjpcmrm6hiCLfXlwZ97Ma4jttlE7Lpr6S/LElU=; b=wVIWniJMkb3Dpi8rusp9LJG5an7idk/Ud8VY4I3y5T+rZBGF446SEFxTJQDLDEAP5D phUkkdul+u0erhZ+vtBNgDZ1lCx3t9rJGULNA7u/dPxaLnw16yyC2Yar1ahp1mqFMznn kZTlWWtPhs2DYkNTqi8YSV32Ik2FQRg3pJrqeywzldcBmcApHqntLSLTjPSTMlzj0DUF 2Kqt8o2F2+cswqmlGE5ZGb8a0EpvZLFPQuZdSqRJFb9iV0I4w+TDSS/wrpTh2PcUvrNi O3NgrKGTH8sMXiP9VEwYKutus+S1R95dRXljX2TRWYpdXVdQWs8BUh7jpj4tl31vfgjZ /YTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724368521; x=1724973321; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u73IhMjpcmrm6hiCLfXlwZ97Ma4jttlE7Lpr6S/LElU=; b=Q6MkzCN98pWHyv2AWqlBGqfIybRmS4gC+iOF1350lXC4QDXrUAD6/sO3RI+LufhOTD ckX9JsSxAgeKAPai9yFIQhyni/sMZeM8agQD7Yzm0HrC50NYT5vhgRlgNU97qsoPEwcp vcbQtSfTfNY8adL+qUobw4/+wUl+qP/JQUu+HYE/3C/bEWJwzYxPuxxeQtgPcTuKpNev /v0nW6k4XMQNdtSgm9zCwG0ndOmho0J0X7et/Q2UTEdz3WrNgVdNfIeqr7s4aLmCX2Sq 7lspXthiNg0bG0A+VEtzbWoKFNnyet8nzCi6+WTJmxsUtgudAJgPMzYiE6AG1Nd5DfAx QZTQ== X-Gm-Message-State: AOJu0YyiXVMLHBwhQBOVSa7hRalLuYLIg8nnPwD6vmgA4LD8KJJPIZdA Ej7jJmccNqP1TN3UvYInVVdxmyGb1G6UDD3HrS0CQB0FtbJIiGHyqsSzgdbcHzUcwKDGtvgsaDj Eb7w= X-Google-Smtp-Source: AGHT+IGheR1suId2YbD74f++i/x4GmzoxXbzy4kRMXUZ1qR5AF5+bO0RDGYNa/bsMobWLIgClOMRRw== X-Received: by 2002:a05:690c:95:b0:64b:69f0:f8f2 with SMTP id 00721157ae682-6c62441920amr4176987b3.3.1724368521059; Thu, 22 Aug 2024 16:15:21 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6c39b007479sm3726477b3.69.2024.08.22.16.15.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Aug 2024 16:15:20 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_D3008CC0-5419-47A5-B8EE-7BF09A7B3249" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) Date: Thu, 22 Aug 2024 19:15:19 -0400 In-Reply-To: Cc: internals@lists.php.net To: "Rowan Tommins [IMSoP]" References: X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_D3008CC0-5419-47A5-B8EE-7BF09A7B3249 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 22, 2024, at 5:32 PM, Rowan Tommins [IMSoP] = wrote: > I was thinking about this earlier, and how the migration is pretty = much the same (and equally automatable) in either direction: >=20 > * If unqualified calls become always local, then every global function = call needs a use statement or prefixing with "\". > * If they become always global, then every local function call needs a = use statement or prefixing with "namespace\". >=20 > But the first option probably requires changes in the majority of PHP = files in use anywhere; whereas the second only affects a small minority = of code bases, and a small minority of code in those. >=20 > BUT, if people already complain about "\" being ugly, having to write = "namespace\" is going to make them REALLY grumpy... >=20 > So maybe at the same time (or, probably, in advance) we need to come = up with a nicer syntax for explicitly referencing the current namespace. >=20 > Unfortunately, finding unused syntax is hard, which is why we have "\" = in the first place (and for the record, I think it works just fine), but = maybe something like "_\" could work? Giving us: >=20 > namespace Foo; >=20 > $native_length =3D strlen('hello'); # same as \strlen('hello') > $foo_length =3D _\strlen('hello'); # same as \Foo\strlen('hello') >=20 If having to type `\strlen()` is ugly =E2=80=94 and I agree that is it = =E2=80=94 then having to type `_\strlen()` is what in university we = would call "fugly," to emphasize just how much worse something was vs. = just run-of-the-mill "ugly." Having to prefix with a name like Foo, e.g. Foo\strlen() is FAR = PREFERABLE to _\strlen() because at least it provides satiating = information rather than the empty calories of a cryptic shorthand. = #jmtcw, anyway. > If I had a time machine, I'd campaign for "unqualified means local" in = PHP 5.3, and we'd all be used to writing "\strlen" by now; but = "unqualified means global" feels much more achievable from where we are. >=20 If I had a time machine I would campaign for real packages instead of = what namespaces turned out to me, and that used sigils that do not = double as the escape character for strings, but then both of us digress.=20= -Mike= --Apple-Mail=_D3008CC0-5419-47A5-B8EE-7BF09A7B3249 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Aug 22, 2024, at 5:32 PM, Rowan Tommins [IMSoP] <imsop.php@rwec.co.uk> wrote:

I was thinking about this earlier, and how the = migration is pretty much the same (and equally automatable) in either direction:

* If unqualified calls become always local, then = every global function call needs a use statement or prefixing with "\".
* If they become always global, then every local function call needs a use statement or prefixing with "namespace\".

But the first option probably requires changes in the = majority of PHP files in use anywhere; whereas the second only affects a small minority of code bases, and a small minority of code in = those.

BUT, if people already complain about "\" being = ugly, having to write "namespace\" is going to make them REALLY grumpy...

So maybe at the same time (or, probably, in advance) we need = to come up with a nicer syntax for explicitly referencing the current namespace.

Unfortunately, finding unused syntax = is hard, which is why we have "\" in the first place (and for the record, I think it works just fine), but maybe something like "_\" could work? Giving = us:

namespace Foo;

$native_length =3D = strlen('hello'); # same as \strlen('hello')
$foo_length =3D _\strlen('hello'); #  same as = \Foo\strlen('hello')

If = having to type `\strlen()` is ugly =E2=80=94 and I agree that is it =E2=80= =94 then having to type `_\strlen()` is what in university we would call = "fugly," to emphasize just how much worse something was vs. just = run-of-the-mill "ugly."

Having to = prefix with a name like Foo, e.g. Foo\strlen() is FAR PREFERABLE to = _\strlen() because at least it provides satiating information rather = than the empty calories of a cryptic shorthand.  #jmtcw, = anyway.

If I had a time machine, I'd campaign for = "unqualified means local" in PHP 5.3, and we'd all be used to writing "\strlen" by now; but "unqualified means global" feels much more achievable from where we are.

If I had a time machine I = would campaign for real packages instead of what namespaces turned out = to me, and that used sigils that do not double as the escape character = for strings, but then both of us digress. 

-Mike
= --Apple-Mail=_D3008CC0-5419-47A5-B8EE-7BF09A7B3249--