Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128431 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 6374C1A00BC for ; Fri, 8 Aug 2025 07:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754636319; bh=qclHx3FFu8im7V6avM+oaNGBxX39Zu731GntunRMXBQ=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=J+HqYvIORLf6n/gJCJxNhWrIHn9+NQHa8Irin8mJpwJQQ4nwPKvVi+4QuAgu9opcy uPFvd8tOUzV9JjOx4PtEeWoe8Md1YCO9esxp37LkcldF0O+RkzJOLiwH5KMqyZS5cf Kis71tnsvNSCwHzTaZn7ATGjeTnD8OYx3yE2sZq/c+qeRKjn2O7iDWJXcy0e41EI0m QaihY7Rx+Ghtj4WAsmZrBVTQAG3732A0YCOBoou6eLOOfcq7u3THsxQNZ/dd6K2/91 2b+1b6j+Gz9yFdn5szbG3AbxMdJT/BSBBSK2CplSnri/IeISCRIRrdY+hhHwt5J1CF P6l6B8563DYeQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9EF8C18004D for ; Fri, 8 Aug 2025 06:58:38 +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-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 8 Aug 2025 06:58:38 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 2701D1D00176; Fri, 8 Aug 2025 03:00:17 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Fri, 08 Aug 2025 03:00:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm1; t=1754636417; x= 1754722817; bh=h3FfL83aAD4hAB5eFHzozj2OgY0+L5INQR7b+hDPGCw=; b=A UAiY1WJ1S+iiqwj/lxZZHdLf9MrMG5oD12o5W+yQqdUlXOOb5iQs2dSVPiN6sg/D usqix4J+eRPi0YYQC80aOJ3XVnHIkoCoqdd+46R1lur34TIVb/Yg6wO4jeiEhSxZ tvAk8mHjv8jYiwtQIVCOcxcaExN1mOQ+bfWPgAbBarPzC3VtDMfNE9rwYmNdA2d6 p4Vh1/vxweRHrJLb1j9hxAD/p18/5JaZRbqP6qeR+eMA6+DyUY0pfU4EtxJxROuZ mihnaUB6b3KasAPlWb74dBN1jtnxHpJyk+xH949g71Pnw1O/8EY06pfXLL7ZRJtU Qp9T2zbzg+Sl6MK+uZaGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= 1754636417; x=1754722817; bh=h3FfL83aAD4hAB5eFHzozj2OgY0+L5INQR7 b+hDPGCw=; b=LvtMYOmg1w4sdP8B5YfIbdkpUzZr6WkLnbZJOElNa07kXopgXEn 35Ihw3PausXEhExlf9OknKxYS0t0+taD8wzkfoLAxRwiLpL1I9+DBZKGeqvTi9ei HCf3aKD01ALjoFzVYUdxqL8wIH2+hqc276F13dJkoobgN6FMlJ/TaZqbVBbRVFb8 OkCxvdrljpJhiwlU4L2A3DqVcirSXxLcpBvV4wvWdUFtDWkLwDEN2ydZUcBRiDTJ Q3Jo+qj5EmCriVI3XXSPn+zVn+9LoD1hf4AWdIJUAjIoK451tO1GXpsyL90H7g2U jGRjQjK7rxAJpxWWSyOkhvaTB+RwztjbPFA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduvdefudeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfn rghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtth gvrhhnpeegvdejudekgeethefggfeltdeiuedtkeektddujeekhfegkedvffffteegheev geenucffohhmrghinhephhgvihhglhdrohhrghdphhgvihdrghhlnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdr tghouggvshdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepledulhhirghhihhmsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughrvggr sheshhgvihhglhdrohhrghdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrd hphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9DF081820074; Fri, 8 Aug 2025 03:00:16 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AzoCpASj9aCJ Date: Fri, 08 Aug 2025 08:59:55 +0200 To: "Mihail Liahimov" <91liahim@gmail.com>, "Andreas Heigl" Cc: internals@lists.php.net Message-ID: <0bc2ccc9-c8fd-4266-a14c-3d6d4feca62c@app.fastmail.com> In-Reply-To: References: <94a57a5c-41bc-442d-a5e3-13eaea29053b@app.fastmail.com> <7acfc0ad-74a1-47c3-92cc-2f6c330bdb04@heigl.org> Subject: Re: [PHP-DEV] [RFC] Optional Catch Block Body Content-Type: multipart/alternative; boundary=2d2d59c1503a4ef4b3cf8940585389f0 From: rob@bottled.codes ("Rob Landers") --2d2d59c1503a4ef4b3cf8940585389f0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 8, 2025, at 08:50, Rob Landers wrote: > On Fri, Aug 8, 2025, at 07:57, Mihail Liahimov wrote: >> Yeah, it seems to be problematic to use this syntax with finally bloc= ks. Perhaps the optional catch block should be allowed only at the very = end, but it sounds somehow doubtful. >>=20 >> =D1=81=D1=80, 6 =D0=B0=D0=B2=D0=B3. 2025=E2=80=AF=D0=B3. =D0=B2 16:52= , Andreas Heigl : >>> Hey Mihail >>>=20 >>> Am 06.08.25 um 13:34 schrieb Mihail Liahimov: >>> > Hi! >>> > >>> > At the moment, I can suggest this syntax: >>> > >>> > try { >>> > // do something >>> > } catch (SomeIgnorableException) finally { >>> > // do something >>> > } >>> > >>> I find that ... challenging >>>=20 >>> When reading the code I now have to go to the end of the line to >>> understand that the second >>>=20 >>> // do something >>>=20 >>> does not belong to the `try` but to the `finally`... >>>=20 >>>=20 >>> And >>>=20 >>> try { >>> // break stuff >>> } catch (SomeIgnorableException) >>> finally { >>> // do something regardless >>> } >>>=20 >>> seems boken due to the missing } >>>=20 >>> But well.... >>>=20 >>> We just have to adapt to something like this: >>>=20 >>> try { >>> // break stuff >>> } >>> catch (SomeIgnorableException) >>> catch (Some OtherIgnorableException) >>> finally { >>> // do something regardless >>> } >>>=20 >>> -- >>> ,,, >>> (o o) >>> +---------------------------------------------------------ooO-(_)-Oo= o-+ >>> | Andreas Heigl = | >>> | mailto:andreas@heigl.org N 50=C2=B022'59.5" E 08=C2= =B023'58" | >>> | https://andreas.heigl.org = | >>> +-------------------------------------------------------------------= --+ >>> | https://hei.gl/appointmentwithandreas = | >>> +-------------------------------------------------------------------= --+ >>> | GPG-Key: https://hei.gl/keyandreasheiglorg = | >>> +-------------------------------------------------------------------= --+ >=20 > What about instead of at the end, we do it at the beginning? >=20 > try ignore (SomeIgnorableException, OtherException) { > // break stuff > } catch(UnexpectedException) { > // fix stuff > } finally { > // do this anyway > } >=20 > Since ignore only can follow a try and any symbol other than a "{" is = currently an error, I don't think we don't need to reserve "ignore" as a= keyword. >=20 > It appears to be relatively easy to scan/read as well. >=20 > =E2=80=94 Rob Sorry, it should have read: "I don't think we need to reserve "ignore" a= s a keyword". =E2=80=94 Rob --2d2d59c1503a4ef4b3cf8940585389f0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Fri, Aug 8, 2025, at 08:50, Rob Landers wrote:
On Fri, Aug 8, 2025= , at 07:57, Mihail Liahimov wrote:
Yeah, it seems to be= problematic to use this syntax with finally blocks. Perhaps the optiona= l catch block should be allowed only at the very end, but it sounds some= how doubtful.

=D1=81= =D1=80, 6 =D0=B0=D0=B2=D0=B3. 2025=E2=80=AF=D0=B3. =D0=B2 16:52, Andreas= Heigl <andreas@heigl.org>= ;:
Hey Mihail

Am 06.08.25 um 13:34= schrieb Mihail Liahimov:
> Hi!
>
&g= t; At the moment, I can suggest this syntax:
>
&g= t; try {
> // do something
> } catch (SomeIgno= rableException) finally {
> // do something
> = }
>
I find that ... challenging

When reading the code I now have to go to the end of the line to=
understand that the second

// do som= ething

does not belong to the `try` but to the = `finally`...


And

<= /div>
try {
   // break stuff
} catch = (SomeIgnorableException)
finally {
   // d= o something regardless
}

seems boken = due to the missing }

But well....
We just have to adapt to something like this:

=
try {
   // break stuff
}
=
catch (SomeIgnorableException)
catch (Some OtherIgnorable= Exception)
finally {
   // do something re= gardless
}

--
   =                     &= nbsp;                   &nb= sp;                  ,,,
                  &= nbsp;                   &nb= sp;                    = ;   (o o)
+----------------------------------------------= -----------ooO-(_)-Ooo-+
| Andreas Heigl      &= nbsp;                   &nb= sp;                    = ;        |
| mailto:andreas@heigl.org    &nbs= p;             N 50=C2=B022'59.5" E 08=C2=B0= 23'58" |
| https://andreas.heigl.org     = ;                     =                  |
+---------------------------------------------------------------------= +
| https://hei.gl/appointmentwithandreas&n= bsp;                   &nbs= p;          |
+----------------------= -----------------------------------------------+
| GPG-Key: https://hei.gl/keyandreasheiglorg       = ;                   |
=
+------------------------------------------------------------------= ---+

What= about instead of at the end, we do it at the beginning?

<= /div>
try ignore (SomeIgnorableException, OtherException) {
  // break stuff
} catch(UnexpectedException) {
  // fix stuff
} finally {
  // do this= anyway
}

Since ignore only can follo= w a try and any symbol other than a "{" is currently an error, I don't t= hink we don't need to reserve "ignore" as a keyword.

It appears to be relatively easy to scan/read as well.
<= br>
=E2=80=94 Rob

Sorry, it should have read: "I don't think we need to r= eserve "ignore" as a keyword".

=E2=80=94 Rob
--2d2d59c1503a4ef4b3cf8940585389f0--