Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126275 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 5F6F91A00BC for ; Mon, 3 Feb 2025 18:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738608118; bh=twQ4yfkaTcEYUtlTDNm8djQLw8HGrjG/oGxYJnJRcPA=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=AZ2b/kKFkGy7tRFbN6ge880hMu8MLrPrdfcF101iD9N+rRydFxMG90AEKmkDInHn4 WKxZatn2sjH5HqWXojTmyKQZhgvffDjmG4PDgQzQbmaIeOZB2kVxpcXNXGne7UrJt7 VAbwyu4OqmyIRXm0Guzi6TDkfll/5+QXBbEe4Z3h6S54eVPdr2dAoE5R9YHMZaEWrq smSRaKQc6+W1GngbnXbOwn3EdgzEqn/abnjE9YyoPXpRZBd1s0wsZLwPglHpSpXVfX JVGBMUSRRi9MolejzPqGhANrA2PX/o7S/m69ANBPp8dbbDtM3d2jP3v5VODKExh9K+ PEwZ4WTFleDQg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CB13418007E for ; Mon, 3 Feb 2025 18:41:57 +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.9 required=5.0 tests=BAYES_40,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.0 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) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 3 Feb 2025 18:41:57 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id AB0E311400CC; Mon, 3 Feb 2025 13:44:42 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Mon, 03 Feb 2025 13:44:42 -0500 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=1738608282; x= 1738694682; bh=twQ4yfkaTcEYUtlTDNm8djQLw8HGrjG/oGxYJnJRcPA=; b=q gn5vVRME20JKXnau2QW+JhDYBf07z1NSBOhbgyqzQIUEXNbz21IouhLxQG9gOeO3 gM2TPZTuU1B1NFBMLZXhUlP/XuwleFTeYwGbEh38lvkDgk7yOrYrrCdu+Ig2N6vz vkpe7S2imQCayAI02iKRaOYhknr0TRX9EFlVA2a3/DuexyYTO9n+At1Q28IqKBEC /LSaIX5P9WvwpAfTtlQDhMNVbqzCyEbpx67dIQXisoJyLCwyj8+0tMKogw1lN6w7 OfuCIk4OFuEhdR3OPo03E4d18YZZ42RPdk4ThFlrQFzyEOhQhtFVueZTC9fvYLLU kGj4MSIOO73QQTTIA6u3Q== 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= 1738608282; x=1738694682; bh=twQ4yfkaTcEYUtlTDNm8djQLw8HGrjG/oGx YJnJRcPA=; b=lzj+f7F7z0ip8trQjOxKVIZ0aVH/HAiFmBxsLkDeBsib401h28I hzolRf/CTSeFfJXtn0/jEQLVoxnQFO4rgT82wXGHT3VIe1WBH18tMue4u7Rj/Wyy ticpwk0tuADIyxrHgnvHP4JHXYhJT9KxIUG354uG/9S7/dfsvcMLHgIXhpK8ruA2 Wq3YPBvcTP7mOY5a7v+w8AHYoa6lU6bGHXZ3KsYftSD3ozPqYc6pfFr8UB64UMoB 98PKe8WgEVCpe5xZ4YqKinr3AWzSMX/Bte7rF7jTN0qVLaINJ0o4oetFRDVWaqEN WfkRDfA2trQNZTbA9VB3qko8sHhADVg0kZg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukeefiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvfevkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpefgff euieevfeefgfekffevjeefheetveeitefhgfehfeehgefgveekjefhfeekteenucffohhm rghinhepghhithhhuhgsrdgtohhmpdhphhhprdhnvghtnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggv shdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplh grnhguvghrshdrrhhosggvrhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepgigvphho iiiiugesghhmrghilhdrtghomhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsth hsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C15E8780069; Mon, 3 Feb 2025 13:44:41 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 03 Feb 2025 19:44:21 +0100 To: "Dmitry Derepko" , "Rob Landers" Cc: internals Message-ID: <883cfc0a-cf18-4470-a21a-ca8470f090de@app.fastmail.com> In-Reply-To: <878EED34-B28D-48FE-8EBE-5929841C12BD@gmail.com> References: <878EED34-B28D-48FE-8EBE-5929841C12BD@gmail.com> Subject: Re: [PHP-DEV] Re: Discussion: making continue and break into an expression Content-Type: multipart/alternative; boundary=dd7dae480bc34bccbe35bb9e09f5cc1a From: rob@bottled.codes ("Rob Landers") --dd7dae480bc34bccbe35bb9e09f5cc1a Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, Feb 2, 2025, at 14:35, Dmitry Derepko wrote: >=20 >> On Jan 25, 2024, at 12:16=E2=80=AFPM, Robert Landers wrote: >>=20 >> Hello internals, >>=20 >> Now that throwing is an expression, it allows for some very concise >> programming. What are your thoughts on making a break/continue into an >> expression as well? >=20 > Hi!=20 > I had similar idea to make `break`, `continue` and `return` be express= ions instead of statements to simplify almost the same cases as Robert d= escribed above. >=20 > Grammar corrections in the PR. https://github.com/php/php-src/pull/176= 47=20 > Ilija pointed to memory leaking problems as well. >=20 > Thinking about Ilija memory leaking case: > new Foo + return 1 >=20 > I think we may have a workaround here, by allowing all of these constr= uctions only available at some specific points: > - as the statement now > - $cond ? : ; > - match ($v) { =E2=80=A6 =3D> } >=20 > So it will deny such cases: > - operand OPERATOR (1 + return; $cond && break; etc) >=20 > It may prevent memory leaking problems. Isn=E2=80=99t it? >=20 > I=E2=80=99m writing RFC: https://wiki.php.net/rfc/return_break_continu= e_expressions=20 > I=E2=80=99ll start a new discussion when it will be ready for it. >=20 >=20 > ---------- >=20 > Best regards, > Dmitrii Derepko. > @xepozz Oh, this was a fun one! I ended up rewriting the AST during compilation (pass 2) to return/break= on the next statement instead of in the current statement. That let me = get around the issue but I guessed nobody would like it and it probably = wouldn=E2=80=99t pass on technical reasons. In other words, yes it was an expression on the grammar level, but it wa= s compiled as a statement. =E2=80=94 Rob --dd7dae480bc34bccbe35bb9e09f5cc1a Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sun, Feb 2, = 2025, at 14:35, Dmitry Derepko wrote:

O= n Jan 25, 2024, at 12:16=E2=80=AFPM, Robert Landers <landers.robert@g= mail.com> wrote:

Hello interna= ls,

Now that throwing is an expression, it = allows for some very concise
programming. What are your th= oughts on making a break/continue into an
expression as we= ll?

Hi!=  
I had similar idea to make `break`, `continue` and = `return` be expressions instead of statements to simplify almost the sam= e cases as Robert described above.

Grammar = corrections in the PR. https://github.com/php/php-src/pull/17647 
<= div>Ilija pointed to memory leaking problems as well.

=
Thinking about Ilija memory leaking case:
new F= oo + return 1

I think we may have a workaro= und here, by allowing all of these constructions only available at some = specific points:
- <point> as the statement now
<= /div>
- $cond ? <point> : <point>;
- match= ($v) { =E2=80=A6 =3D> <point> }

S= o it will deny such cases:
- operand OPERATOR <point>= ; (1 + return; $cond && break; etc)

It may prevent memory leaking problems. Isn=E2=80=99t it?

I=E2=80=99ll sta= rt a new discussion when it will be ready for it.

----------

=
Best regards,
Dmitrii Derepko.
@xepozz<= br>

= Oh, this was a fun one!

I ended up rewritin= g the AST during compilation (pass 2) to return/break on the next statem= ent instead of in the current statement. That let me get around the issu= e but I guessed nobody would like it and it probably wouldn=E2=80=99t pa= ss on technical reasons.

In other words, ye= s it was an expression on the grammar level, but it was compiled as a st= atement.

=E2=80=94 Rob
<= /div> --dd7dae480bc34bccbe35bb9e09f5cc1a--