Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:129190
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 717F01A00BC
for ; Mon, 10 Nov 2025 18:53:16 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
t=1762800801; bh=Rg4ITh6VmXBU04Eddsh6f4sxvNwFfCFSOMqkTlOyGeU=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=BvJmjDyp3bj4EyjExB8f22g7Y9fz6Jjc8pU7D0Cvn5L06fduJcpEz3P7cXajFxkMt
CPZRm9kzsbd2uKKfg9/tahpT+BIYdADSM3VDgo5O5u+LvaETaC0eXSajbT3yHCJpXH
hXkv9IhIoh6uKgWNJSeQnYBQpSgtXLiCPzcxMmVKte+aGCtwR4ryyuePktFGI8++Y2
Nz3RbOBLKVACLV81QCLz+zOdYGLBbUabklKTM9b5v2ZCsNCFk3Xi+pCQUsRkJ0WNx4
tRxIkQBvK8Fs73JqA8VvkRVyqOf4dS2m+9Kqeh8FuOOdCzW8L3FbJHFA5o2lHKf7YV
AyG2zUj5XTdjg==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
by php-smtp4.php.net (Postfix) with ESMTP id 1CF59180386
for ; Mon, 10 Nov 2025 18:53:20 +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=-2.8 required=5.0 tests=BAYES_00,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.1
X-Spam-Virus: No
X-Envelope-From:
Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150])
(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 ; Mon, 10 Nov 2025 18:53:19 +0000 (UTC)
Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51])
by mailfout.phl.internal (Postfix) with ESMTP id A131CEC2064
for ; Mon, 10 Nov 2025 13:53:13 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
by phl-compute-11.internal (MEProxy); Mon, 10 Nov 2025 13:53:13 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm3; t=1762800793; x=1762887193; bh=zEJdS/9WYq
ZADwcsM4hYIYkUDTJA6UDJHt9qq8BTvf0=; b=L2lN7BQkCrve+MW/A8xbvLjJaJ
jhVbmfWmmBVyAcG6G94GdyPEMbiMORkycnFiGtTDWQ2zc3AjR5S4AwfZSTPsoC1Z
d6ofI1dynJAXORRjq6evl3w8xO+LiEZIRqJFKnvgvs8/TLCpz4xDVJEXNDA+w/Og
84OJztXrcn8AbnOburdWPkdfVl8MIx0JXTzyJcSsdVC9LpuP3RvC2W4VpOvY9biX
srdJxOk/D+B/Ydb6G5M/Zw9az9nZ1G1QqI5oIvbbOxj9wpvA24YC/w27WsxOrlk+
FZzxrFH7orFtiZldKibkEc7xTLIplm1rLITgIXKUqzzoB/00w+cAg0/42v/Q==
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-sender:x-me-sender:x-sasl-enc; s=fm3; t=
1762800793; x=1762887193; bh=zEJdS/9WYqZADwcsM4hYIYkUDTJA6UDJHt9
qq8BTvf0=; b=HwC9ebG+9Q8onuDODRQKsz5018LRS5alLVMOLzgRxy59HFbAafJ
D5KUITgTbgHYJhY70CMB+w7XX5gXZYOq56RurKG8thyknxLqz6134spDfAL9tHVu
+x1mpjNR1tKRaD1GD/rTLKNWbyaE4FIcrNHIztRrQ4PvEkABrUXeC1zNz+HLhtUf
+571TYFXjKKueGZr2y/dG53V7jprEdztwSGu0TIzXMBfU3S+jgSjia9FfS7l2HL1
h0iy3oXtSXE2qQrmvoLG8/LGWK4i5eeLPOvW5WR4WiXXYjEOQ7JyMRwXKwGVae2a
3OjphEViwpw68ceo2Vie9AXNRtBbB47siEg==
X-ME-Sender:
X-ME-Received:
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduleeltdekucetufdoteggodetrf
dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu
rghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffvfhfhjgesrgdtreertd
dvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehi
mhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhepveelue
ehteffledvgfdugeelvdehhfeujeegieelueehhfelvdffgeffuedutdehnecuffhomhgr
ihhnpehmihgtrhhoshhofhhtrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg
hrrghmpehmrghilhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhn
sggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvg
hrnhgrlhhssehlihhsthhsrdhphhhprdhnvght
X-ME-Proxy:
Feedback-ID: id5114917:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
; Mon, 10 Nov 2025 13:53:12 -0500 (EST)
Content-Type: multipart/alternative;
boundary="------------KTCWuMFWzmxTdi3lRcOydZqE"
Message-ID: <1418f5e7-d43b-480b-b843-df9978d231c4@rwec.co.uk>
Date: Mon, 10 Nov 2025 18:53:10 +0000
Precedence: list
list-help:
list-unsubscribe:
list-post:
List-Id:
x-ms-reactions: disallow
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PHP-DEV] [RFC][Discussion] use construct (Block Scoping)
Content-Language: en-GB
To: internals@lists.php.net
References:
<4bf2e8023b934e73e0832c8dc3ddeb3c@bastelstu.be>
In-Reply-To:
From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]")
This is a multi-part message in MIME format.
--------------KTCWuMFWzmxTdi3lRcOydZqE
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
On 10/11/2025 13:24, Arnaud Le Blanc wrote:
> As I'm seeing it, a File object that was explicitly closed would throw
> an exception like "FileIsClosedError". It would indicate a lifetime
> bug that needs to be fixed, not something that should be handled by
> the program. This is reasonable, as closing is a clear intent that the
> resource should not be used anymore. This is not an exception that
> needs to be handled/checked. Under these intentions, leaving the
> resource open (for the reason it's still referenced) and allowing
> writes to it would be much worse.
C# / .net has an ObjectDisposedException for this purpose. The
documentation does indeed advise against catching it:
> In most cases, this exception results from developer error. Instead of
> handling the error in a |try|/|catch| block, you should correct the
> error, typically by reinstantiating the object.
https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception
Note that using() does not prevent this. For example, in the
following, the using() block will implicitly call ms.Dispose(), but the
variable is still in scope.
MemoryStream ms= new MemoryStream(16);
using (ms)
{
ms.ReadByte();
}
ms.ReadByte(); // throws ObjectDisposedException
Similarly, additional references to the object can be made with
lifetimes which exceed the using() block:
MemoryStream ms_outer;
using (MemoryStream ms_inner = new MemoryStream(16))
{
ms_inner.ReadByte();
ms_outer = ms_inner;
}
ms_outer.ReadByte(); // throws ObjectDisposedException
In Hack, I believe both of these would be rejected by the compiler,
because any object implementing IDisposable is subject to strict usage
restrictions.
--
Rowan Tommins
[IMSoP]
--------------KTCWuMFWzmxTdi3lRcOydZqE
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
On 10/11/2025 13:24, Arnaud Le Blanc
wrote:
As I'm seeing it, a File object that was explicitly closed would throw
an exception like "FileIsClosedError". It would indicate a lifetime
bug that needs to be fixed, not something that should be handled by
the program. This is reasonable, as closing is a clear intent that the
resource should not be used anymore. This is not an exception that
needs to be handled/checked. Under these intentions, leaving the
resource open (for the reason it's still referenced) and allowing
writes to it would be much worse.
C# / .net has an ObjectDisposedException for this purpose. The
documentation does indeed advise against catching it:
In most cases, this exception results from
developer error. Instead of handling the error in a try/catch
block, you should correct the error, typically by
reinstantiating the object.
https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception
Note that using() does not prevent this. For example, in the
following, the using() block will implicitly call ms.Dispose(),
but the variable is still in scope.
MemoryStream ms= new MemoryStream(16);
using (ms)
{
ms.ReadByte();
}
ms.ReadByte(); // throws ObjectDisposedException
Similarly, additional references to the object can be made with
lifetimes which exceed the using() block:
MemoryStream ms_outer;
using (MemoryStream ms_inner = new MemoryStream(16))
{
ms_inner.ReadByte();
ms_outer = ms_inner;
}
ms_outer.ReadByte(); // throws ObjectDisposedException
In Hack, I believe both of these would be rejected by the
compiler, because any object implementing IDisposable is subject
to strict usage restrictions.
--
Rowan Tommins
[IMSoP]
--------------KTCWuMFWzmxTdi3lRcOydZqE--