Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129104 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 C27311A00BC for ; Thu, 6 Nov 2025 02:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762395962; bh=SJsWA0G3b47hAqZtfvbkKTVV6Z+gGnnSQ+RX2VSe5hE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YZH28dK8G1PSdT96AnkG0V61O8x+LYzoRaPVy+yOrRf7A+EhBf8KZdcjFB5bCM4Ut 7u9EBhoBtLzZl3Dg4APlapo5cTXbI0OUOO5GrbvqhtoRFVT3WfQsc2FtBqeBysvDac 82SkD5VfQ1w3ypmfy1glBw7BblkqH7ESHh7XYpe4MN4Xz/JZu96Qe6KvgVjQF+c18f kruxrUsHtPBU027pBhztSEdlWYWJfLhB/ezQxGz5lpdONxIUm9RbhWF/2a6+kmfn3y tkihazfGvIpB9T/MtcJErytLIYUtd4svAOfui/ggycnhl8tm2kVGctDbCzsu9psERq 4xxKIylZSuovA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 91E3F18003F for ; Thu, 6 Nov 2025 02:26:01 +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.5 required=5.0 tests=BAYES_05,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.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.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 ; Thu, 6 Nov 2025 02:25:50 +0000 (UTC) Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-5599688d06dso90129e0c.2 for ; Wed, 05 Nov 2025 18:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carthage-software.20230601.gappssmtp.com; s=20230601; t=1762395945; x=1763000745; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SJsWA0G3b47hAqZtfvbkKTVV6Z+gGnnSQ+RX2VSe5hE=; b=LZcGYszFL7pJtxZt8wX0cD94UElj2vqQwwEUjuc1QygKsUJ89dEbhdWFcUYdgDgCM7 7vF1Zg1XnaxhFAu0Kixpc//yAoclLeeqPAzTAXT9LQfjcrYzDsawjyOP1J6dNZtTuN5B ifwRGR2BRWKGTw/La5g8WBou4OiF3wOZJOliOCy46qQLQDGHnNG211OyC7AqN3fyQQR0 zGrsgn9oxYA/5ScAnzwPf57dJ9NXsVgElHwa+vbCYpDqZG1KY09trm7iOB0AW12XABb2 Z7dHeFTigfNXAD2iP0VPqAVO1r4hYjiN5/FF4DgK9f/PiRg6VnCr/95C4ifsfaRgTxt8 jAjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762395945; x=1763000745; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SJsWA0G3b47hAqZtfvbkKTVV6Z+gGnnSQ+RX2VSe5hE=; b=N0eBHyXRsYKrtml+Kr18zZCsi7F/TRTk36kiFyPgPiJJx02TmZXYE3AX7K149KU7cX gxybnSLnv3a+9+5UnA8r9rr1GkDuiC9E5k8mwISqNPGN6RC52+IwC9MSyGhDqWL9Jyad UWvKMrUzo4cgw53FZQ0vF0HHZDk8xKpkxX9kPVqpBKyoDF5XGhWtHvbNPgLpt/qbp9/Y gQDZy5k0gymy4Hpp9ZSkz9A1gWnbXrsbSm3D2KneokrTpjmbGRBGBPVso/yt2RFHx4nU emmhnn+qn+Gmnm6vzDVcg0dolxctrc8D1rSnICFkhgps3xN2IDaoYdGbjcr19kgrufJi q4wA== X-Gm-Message-State: AOJu0YytnpqxW0FfvQL4PwqgUWMgKnR5UrU1hy52YkRnb+XsefGyJ/0d MOwdAleko5U772DuWNwNctH+CVb7BXSdQlVha7GlohOf+ztb6mcX/y2K74aEPPKIefyHZyjY/Hb vz4HEnuIzInnerJw6YSnt9BAwtS1Zx9IMATmv8iJcK6a9NigA2fvtCU5f2GYG X-Gm-Gg: ASbGnctstCkb4R6R9R1eVacz7HP3R62IHtloH/UpLe32MJrvcGZ94wHWoyE1s6TGit0 AqoaMIPa258N3U8x12ulsQUS3h8pNeDb8IZGVVQvRnXEaSkMMAixRF3jc4OzbxB8ufSINkGC2hc oNxzM4oXj5TjRJ+W335KvZuYD4jwZkuVh58R0apM2kVUMWF5qr1Pq7f4QpGSfP63oLL85qpV1vw UvvT9XhUhlKoFbm3ltiJQQa75W1zlhupsjcxBD8jAv7s8jUwd4/Jcvof4OpllxW18Ad3rdJ X-Google-Smtp-Source: AGHT+IEMfqMymyWzKkCJaNEuj0ldqWep/ZgrHHFeyD4umZMWZyt01QXcauhEJ/E8T9wq4CL2Hi+DGNrGhPrFulo+USE= X-Received: by 2002:a05:6102:38d1:b0:5db:ecdd:1826 with SMTP id ada2fe7eead31-5dd891fc349mr1999375137.22.1762395945168; Wed, 05 Nov 2025 18:25:45 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 6 Nov 2025 03:25:34 +0100 X-Gm-Features: AWmQ_bmyMujMvoaS5fj7i1rKJYYqB068qx2k-Ha3vClD5-dOjJGD-hx4tMwfeI4 Message-ID: Subject: Re: [PHP-DEV] [RFC][Discussion] use construct (Block Scoping) To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: azjezz@carthage.software (Seifeddine Gmati) On Wed, 5 Nov 2025 at 21:18, Rowan Tommins [IMSoP] w= rote: > > On 4 November 2025 19:44:40 GMT, Seifeddine Gmati wrote: > > >This mimics Python's context manager protocol. The `dispose()` method > >would be called before `__destruct`, allowing objects to distinguish > >between successful completion and failure. > > > A clarification here: this would be equivalent to IDisposable in C#, but = it would not be equivalent to the Context Manager protocol in Python. > > The use cases which motivated them are actually quite different: C# neede= d a way to handle things like pointers to unmanaged memory, so the design i= s closely tied to the actual resource object cleaning up its own internal s= tate. Python was looking much more generally at common programming patterns= , and a "context manager" can be separate from the resource it is managing,= or even have no associated resource at all, only "enter" and "exit" behavi= our. > > > > Rowan Tommins > [IMSoP] Hi Rowan, My statement that it closely relates to Python, is in the sense that if we were to add a `Disposable` interface, it would need to add additional value beyond what `__destruct` already provides. In C#, `Disposable::Dispose` ( just like in Hack ) receives no information on whether the `using` scope exited successfully or due to an exception, so having this in PHP adds no value that `__destruct` doesn't already provide.