Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129403 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 lists.php.net (Postfix) with ESMTPS id C84C11A00BC for ; Sun, 23 Nov 2025 14:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763907831; bh=IcZuUIENlb39+h7swYyTcrR6uVsRHPCOqbWXXO/TDok=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=CRJaeLUFvHeJ03JTTxNZbFiDjcIydyww6GH1L1PIPvdgj4oCSO1RfHlz1/ezQKhAo IEnLdcig7RhdQd9adqBzghfphaSto2o7TqnWFetS0HQHR9QI1bba3MglEbul+/Mfcq aO6GXZB+JYC0kCQ7IMGJLK4ldfyznPnniYKvl76dy3TBffB4ZJ9ykC0B8ILD55vgcV P9bsPtqHiTwtuuXbvmVJSgT7uiqW9VEHK8mm9ZwxqYOZbRUyHIow283TdoU30k1PeE 2ZXTxe9wz213h9UXXyySdwZumxIJHCfBYFjs44SO+I2BrSSa5ZSYvzDLttAw7QJ09o oFrjDaKbOZNpQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8757E180040 for ; Sun, 23 Nov 2025 14:23:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Sun, 23 Nov 2025 14:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1763907823; bh=z/eay5u6Km53uLObc7EUMe211h52YHS7PetR3Fadz7E=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=c/dlfQcs7HcDx2fjx42/byN4hk9893NrDc8JQk27yMUoJSoNY5EzDiW1A6KWkOxi7 PQeIGIJq6eF7/Z2CpddPWIjSVKx3PIjPM91knspQyHuiR8KcWxkKaux3lPqrp+UmUw oxe0GMDsupHZGT5Mrlt/utuGMtdRukkZ1fuzbXWUvkNzz/njYt1S+DxwDErciwlGuq 0kbQFzyyTfwqWwF/xIdZahwNmmZG0+PazYLzGJb5OIJ+DtLuI9gTkWvS/FycRdhKwD 9SbXr52N+NKKznqBcH4AkD0U7csrlu24AQEOfXvWoc5w43/W7mOX0MH9N2Woi0D8EK QSjT37lwEPaMQ== Message-ID: <590fa655-d170-43f2-984c-d0a5ff6c30e4@bastelstu.be> Date: Sun, 23 Nov 2025 15:23:40 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC][Discussion] use construct (Block Scoping) To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net References: <1F3473C7-5D83-48D3-964E-A63D6F44D21E@rwec.co.uk> <4998b4c6-0474-4f0c-b63a-9909b8acfa96@bastelstu.be> <018421f64342a0d960589b4c8eea5cc5@bastelstu.be> <84b9dc16-3eb3-4283-b015-3af29fc0e55d@rwec.co.uk> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 11/12/25 10:53, Tim Düsterhus wrote: >> I do see the advantage of forcing them to the start, though. Languages >> in the Pascal family might be another comparison to explore - variables >> are all declared in a separate block at the top of a function. >> Off-hand, I'm not sure if any allow an arbitrary nested block just to >> introduce additional variables. > > We'll look into more research in that direction. From what I see in Pascal you would need to declare a “nested procedure” that can then access the variables of the outer prodecure, not dissimilar from a Closure with autocapturing. We have now added a “Design Choices” section to the RFC explaining why we opted for “declarations need to be at the start of the scope”: https://wiki.php.net/rfc/optin_block_scoping#design_choices While it does not directly compare with any language (except for JavaScript), it mentions auto-vivification and scope-introspection functionality, which as far as we are aware doesn't exist to this extend in (similar) languages with block scoping and which is an important part of the requirement. It also points out how it will not require additional nesting in practice. When there's already a block (particularly `if()`), one can put the block statement directly into the construct without additional braces. Given the previous opinions of “please don't overload `use()` further”, we also renamed the keyword to `let()` which fits the “block scoping” semantics best, particularly when also considering the possible future scope for `foreach()` scoping. Best regards Tim Düsterhus