Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125458 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 7C32E1A00BD for <internals@lists.php.net>; Fri, 6 Sep 2024 19:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725651865; bh=mn/sklMZSJRzJ1UkX3mr5t4N9WEMACRq+FEmpYFmQoc=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=NThRVn5VwOZzA+VcG2jjhuyKRCxumAt6Sr6vKQ3sZuoySgkODnieWiLcOvSSebec+ 7gNWUYTxiN+sg5L1Jgp3/Jbbx663IGdtuStW6mpKxN45+dEfj9eGZDpprdJGcnAeJb 5S813vy+SwDqwpMxQXmiucILQYXVrTyx9ueAqf02Pe4hGUXwauIf2DgZYrenO4TFzK qAo71KZSRmnZRz79F3rV0SaOXcEWOHcsscxyj2ZtjQPMlP0YMxSVwhO0XafQ5k+YQU ZFdXY2w0K3fD+BSYVYMVb9+S/ZLLBiwLBQ0yKFVPAPMLqKIZxsOa5+lM8aqVFjX5N9 XNdeSA8+yXMTg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 800B51801E9 for <internals@lists.php.net>; Fri, 6 Sep 2024 19:44:24 +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_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <mike@newclarity.net> Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 <internals@lists.php.net>; Fri, 6 Sep 2024 19:44:24 +0000 (UTC) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-6d6a3ab427aso20328127b3.2 for <internals@lists.php.net>; Fri, 06 Sep 2024 12:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1725651744; x=1726256544; 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=cQc3S7g0tPRB0/WvaixUGZsvhsNIuOlI6r16f3gp3Eo=; b=wS4N+rSXWxUfZV0e7kh5sgwmvSaoRp6cpuhJ1SkFq58xYAZQBRLESmDacWAG0Uvyyz rVZKBJyDEomYBTOEbKfKf91/jZ2wV5J6PbqGMujTHAEgN7aja8zsovY4O9MB0xoUKxJp FOzQf6geIAR94pUwNLFRMvv3jwK9YYfztEb2zQIv9H9SrnPXp+DbR3NLCWq0GBuCn9K5 HYyfOgLpnxhlDaT3iDbnHJaaQ5E00xm9JZWI3aGzNb7Xx5QkuDpL5qysKZYlCenYLudX 29ChWsqDs8RqYpkez8vAbomCRbhIL8yauPtu/AIu+JkqH4S5scgGG8ZuqoXs5eTBuI7s tugg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725651744; x=1726256544; 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=cQc3S7g0tPRB0/WvaixUGZsvhsNIuOlI6r16f3gp3Eo=; b=WW9pTJEFU9ne7w22Bnm9VVk3qXKBLZze7v/2n54Fb2+miC6n/APkHR2EtbJw0Of71Q 9i3BMO4LPxtdGB1WiKUg4Xh2vpwETCRSyZ8p3n9F/PhwsWwaDt/sEy3dF/YWeJLo6LiI xkOigFRS1LDUhqB/yAKJSdqAdHptC74ktv5jVJnZXaXHhe8WN34wo92Ky8EsbpxPhsvL 9TI+iCBmTBCVIYu/x1VRy4m2IhwDZhtnxSMVyIITStvdKFJKOhQ/LH7IEK9On9FY5e03 eLoKcyXolv3uZSTLiA6I5BFyAXZoUMMGIRpHIiAdWLp7ZDDgk3CAmL6T0Le55F/PqZ4g sfSQ== X-Gm-Message-State: AOJu0Yzr1gJZXTapSxi2lVXWgBSjFfsD4ANPgICNXrYNs6+VyiUfIHoc oJRijD78ehMJSDuCxI5vaJo/NiZFthR79c8ywu26An7vQnqGhF0BE+Wc0vtw1haclSYAmnhD7Os k7u0= X-Google-Smtp-Source: AGHT+IFQbdzbDS8HlfE36sh91Y8HEI6Rtc+sQEe+aWjQU9Bxzze0/KZprZ2hT41GZN9nc4jDEv+8Pg== X-Received: by 2002:a05:690c:ece:b0:61b:1f0e:10 with SMTP id 00721157ae682-6db44d68ad9mr49973457b3.4.1725651744097; Fri, 06 Sep 2024 12:42:24 -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-6db565c7c48sm1109687b3.117.2024.09.06.12.42.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2024 12:42:23 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Precedence: bulk list-help: <mailto:internals+help@lists.php.net list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net> list-post: <mailto:internals@lists.php.net> List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.10\)) Subject: Re: [PHP-DEV] Local constants In-Reply-To: <5d6f5a8b-05c3-4519-b5e0-1c8c51b9d626@app.fastmail.com> Date: Fri, 6 Sep 2024 15:42:22 -0400 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <C76B2495-ECC6-4A5F-9B1F-2CC6E9064325@newclarity.net> References: <CAPbW5OMLM=0k_WkL1K556O3+cq06X3iQ7OwgPWyjcUzBJ7opRA@mail.gmail.com> <27c3909f-05f4-4256-a447-10e8d8760fff@app.fastmail.com> <F9C739E2-2FA3-4CAF-9A9B-CE343F84B461@zort.net> <420bb5cb-5fca-4f2e-8c68-0ca327cd3392@app.fastmail.com> <7A98532B-7465-4FC5-B7A9-993E7D430EE1@zort.net> <94510a5e-ae23-4118-ac55-2e90c911e7da@app.fastmail.com> <77C2D2CC-5E1E-40D9-9FB3-A5C4A6311669@newclarity.net> <ED7A6AE0-75FF-4765-BF46-F0A3206473D5@rwec.co.uk> <9045A1B9-2880-4FB4-88F4-1AF7EBF0F3E0@newclarity.net> <5d6f5a8b-05c3-4519-b5e0-1c8c51b9d626@app.fastmail.com> To: "Rowan Tommins [IMSoP]" <imsop.php@rwec.co.uk> X-Mailer: Apple Mail (2.3696.120.41.1.10) From: mike@newclarity.net (Mike Schinkel) > On Sep 6, 2024, at 4:47 AM, Rowan Tommins [IMSoP] = <imsop.php@rwec.co.uk> wrote: >=20 > On Fri, 6 Sep 2024, at 03:01, Mike Schinkel wrote: >>> Block-scoping doesn't have to allow shadowing of names,=20 >>=20 >> How exactly would that work? Are you suggesting to restrict the use = of=20 >> variable names to one per function but still allow for block scoping? >=20 > Yes. That's how C# works, for example - variables are scoped to the = block where they're declared, but each name declared must be unique, not = shadowing one that's currently in scope. Interesting. That seems... an odd choice, just to enable block scoping. =20= BTW, I find block scoping has more pain than pleasure, even when it is = not exactly causing bugs, e.g.: if (is_null($widget =3D getWidget())) { return; } echo $widget->name; // block-scoped $widget not available The above would actually be a runtime bug in PHP, if the code were not = covered by testing beforehand. In a statically-typed pre-compiled = language like Go, it is just an annoyance. OTOH, I very rarely ever find a situation where I am actually happy to = have block scoping. IOW, I don't know what it enables that make people = want it so badly, except possibly conflating closures with = scoped-blocks, or ability to further control scoping in (too) long = functions. I think features that would reward people for writing shorter functions = would be much better, but maybe that is just me. >> Shadowing is not a feature that is added, it is the result=20 >> of block scoping, AFAIK. >=20 > Shadowing is absolutely a feature that has to be implemented: the = compiler has to store some "backup" of the old name binding, so that it = can be "restored" when the shadowing variable goes out of scope. Without = shadowing, it's instead about tracking the "lifetime" of the variable, = and refusing references to it outside of the block where it's "live". = I'm sure the implementation of both versions varies wildly. Meh, you can twist words to mean that, but your words ignore that all = variable scoping is then explicitly implemented as feature.=20 What I meant was the language already implements variable scoping so = there is no additional work needed beyond what they language already = implements. Unless the language was weirdly designed in such a way that = it cannot reuse existing scoping mechanisms, which I will admit may = actually be true of PHP. OTOH, I am not speaking of what you just revealed about C# which I find = to be also be, weird.=20 > You're right, there is some value in letting people know that a = feature would be popular if implemented. I'm just aware that threads = like this can quickly grow into rambling discussions of wild ideas with = little grounding in what's possible, or back-and-forth debates between = two people about something completely hypothetical. When that happens, = those with the experience to actually implement big new features tend to = tune out.=20 With respect, local constants and/or immutable local variables are = hardly "wild ideas," nor likely something that has "little grounding in = what's possible." -Mike=