Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125123 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 BF77F1ADBA9 for ; Fri, 23 Aug 2024 11:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724412664; bh=LL6inaGbvUn89AK7vMLc7yA9g3aZavtRjmV9WcghrpM=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=kfUAI3r4feSZYs93rw1YjPF75eHvVnVG2zzaLc0bL/UGKjBLsebHU0ab44lPiiC4w 7qeRiKxH3WIup+68+JP4I02mmAI+qwr9NQ7p7TRyf3+GnsMaQME52ayPg7RaxI0YeJ lOIKKx+TdqqbjCEp6BPPcyiLodhlxNbZnuTHa06zc5tnD4JBdNf+VSSqhE3GiAXz3d PPuPuFUL0kb25+U38w/Znw3PHOirIQfCdVwNXrjbjJ6gF/jWhFBQAcRfcCyPPo1hlF yzUvN9DthuunxLU1/Vng4ORcxeLvvIVXlyyKA1x4OQnDBmKtbWHrTX0ATKsaeMHMXu d/2eYrpWJlK+Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CAAE01801E0 for ; Fri, 23 Aug 2024 11:31:01 +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,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-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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 ; Fri, 23 Aug 2024 11:30:59 +0000 (UTC) Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e16582cb9f9so1442033276.0 for ; Fri, 23 Aug 2024 04:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1724412548; x=1725017348; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FUvM8YVMJDvAOdoqtiUUgwQl3FFoH21z8o8GKxvxW4I=; b=TOgZeek7gxvCl0/9rBIll+4wT/PqxOMSY0qeWLQYYd3OvOCBErzRapo76NrhMB2MH2 cqv6MjEvpav3GY+G8Wivpesju+cYU3Yyyf9XkyoiLfk+R/LW52lKphuwzSu9eHXJ2lAD A7xVXh8OTe4tRBFtbDhUL49aTdJ0bVYd5RSNtjXGuVbNMZs6FMIS4FJcxrZggC4cTW4M jus+in+8xCz3jW99N5eKJfHLIedvgoxO0x1WjUIZ9od5hVnWeCaQ2TNjC7upebJHGdfK MKhM9DRPUYLvhsAfM2zgnrQEc1twRIg4qiRqfi0MHPaCWQsDe/I/JExrVNby4HI/W4gO JlDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724412548; x=1725017348; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FUvM8YVMJDvAOdoqtiUUgwQl3FFoH21z8o8GKxvxW4I=; b=nHdGO+5JzRQZOVpmKyWLrZcdkgzEOsqqZgWzXBYm/wpklKKI5d9E7n+eprqlGfRTNC RQEJ5CmPpsP8dPl/6FCineOBuw4OO/2PYC+BncroQ65Ft4nBZVsYacT+RdI1OtV7IJqw ulpqIz92chWUa1ITbEORAZF44SOOsemXeEfe//TptiUEwKp+8Sa/GC14AJsE2p8yLYAZ f2MqrPVIivYCyKccSJRxvdIQKteQ2jUvETJ5SbQB1mPnu7TKspz3rQxHnOm7GIzyO2XS 6cNX7p6ZLdeAfE2N5kBuK0ZlvSDgRE6R5koPGSJ+L/ZTDLJuFYanAP0ZGgxkBK51xvpQ VOiw== X-Gm-Message-State: AOJu0Yzs2E4cgYzAFCUA5k3PobVnJNvJThiVIc8xFKcD7OisDOc/vpy8 JUAtWF4K7T6k2oanGhi3qbFCR2kljXOd+qPnIKRu3RPzmaLbwmjwfWB4FNDbt8k= X-Google-Smtp-Source: AGHT+IEwTKhwVO2NRDE4Giq+1Fwz14fynr4qAxkqAf5ZNltPV+eIc3iVmp0kFWJoEw9vVc3WEsh0bA== X-Received: by 2002:a05:6902:15c6:b0:e0b:b11c:2f42 with SMTP id 3f1490d57ef6-e17a7a43eb1mr1482750276.17.1724412547584; Fri, 23 Aug 2024 04:29:07 -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 3f1490d57ef6-e178e56a5f7sm640129276.44.2024.08.23.04.29.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 04:29:05 -0700 (PDT) Content-Type: text/plain; charset=utf-8 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) In-Reply-To: <846D7756-712B-4A7C-9FC6-DB9F858836B8@rwec.co.uk> Date: Fri, 23 Aug 2024 07:29:04 -0400 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <846D7756-712B-4A7C-9FC6-DB9F858836B8@rwec.co.uk> To: "Rowan Tommins [IMSoP]" X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) Hi Rowan, > On Aug 23, 2024, at 2:39 AM, Rowan Tommins [IMSoP] = wrote: > On 23 August 2024 00:15:19 BST, Mike Schinkel = wrote: >> 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. >=20 > I knew I'd regret keeping the example short. Realistically, it's not a = substitute for "\Foo\strlen", it's a substitute for = "\AcmeComponents\SplineReticulator\Utilities\Text\strlen". And similarly, I too regret keeping my answer short. I was assuming what = I omitted would be obvious.=20 (And I am not being snarky, I literally thought about including this = next but then felt I did not need to. Hindsight!) So, long namespaces is why PHP has the `use` statement, making = references in functions short and sweet, e.g: namespace \AcmeComponents\SplineReticulator\Utilities\Text use \AcmeComponents\SplineReticulator\Utilities\Text function Foo():int { return Text\strlen("Hello World"); } (Of course, that is a lot of redundant boilerplate.) > Another option would be to find a shorter keyword than "namespace" to = put it in front. "ns\strlen(...)" is an obvious step from what we have = currently, but it's not very obvious what it means, so maybe there's a = different word we could use. So rather than all that boilerplate, and rather than yet another special = set of characters developers would need to learn and remember =E2=80=94 = and tooling would need to adjust to =E2=80=94 we could instead easily = add an automatic `use` statement for every namespace, as long as no = existing use statement conflicts with it.=20 An automatic `use` would then give us the following, which provides a = strong information sent and is really consistent with the nature of the = PHP language: namespace \AcmeComponents\SplineReticulator\Utilities\Text function Foo():int { return Text\strlen("Hello World"); } The above of course could result in BC breaks IF there happened to be = existing code that referenced Text\strlen() where Text was a top-level = namespace, AND that code was not remediated when this change takes = place. However, I am guessing those collisions would be pretty rare as = both the namespace and the symbol would have to match to be in conflict. > Having a syntax for "relative to current" is incredibly common in = other path-like syntaxes. The most common marker is ".", and ".\foo" is = literally how you'd refer to something in the current directory under = DOS/Windows. But unfortunately, we don't have "." available, so I = wondered if "_" would feel similar enough. I'll be honest, the association with the relative path of `.\` did not = occur to me when you presented `_\` so after you stating this I pondered = if from that perspective.=20 However, frankly, I am not sold on that perspective. Something about it = does not feel right. I can't currently give any more objective arguments = than that, so I will just leave it as #jmctw. I will say if we were going with relative path, I think `\\strlen()` = would be preferable to `_\strlen()`. Subjectively `\\` is easier for me = to "see" and thus does not look so out of place to me.=20 OTOH the objective arguments for `\\` over `_\` are it is much easier to = type: slash+slash vs. shift-underscore+nonshift-slash. There is a = precedent in URIs with `//`, albeit not exactly equivalent. And finally, = it also does not use a sigil that could be better used elsewhere in some = as-yet-to be agreed or envisioned future use. #fwiw -Mike=