Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126269 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 AD2111A00BC for ; Sun, 2 Feb 2025 13:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738503181; bh=2V+ApwbpNmKJZ3OAereuCvxeoHvVTrJo2pwvt7/rgZg=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=PYGeWtZ1SSTJbhJP+d6K9MCYacIvfuKefRCZJycx7/rybWqnRBOdvLwiuZyt0TTcI R+NehzK92CBtRlNX0l5DwyBc+6miaaWqxi7r8VYyIi4L5VanUMGByfD+5V0hOROI+O eV9wH4nPAgPAhvkXHBCOVH0LL2AzkxWXRr4MbyadCej71yhBk/tX1EuE9d4tNdhYCT a1XzLp3JXiHmVldhopBH09qvU1OvReJ8sq91X+uuhuFKKlaMCqhw6aw9C1J91HwhSx Lfy/Vk9/7ghz4tqWXLRwnBBtjO6GY/9rsN9HuGfzYUvcpIEtr5iSOFbdwhAjOSFmR4 WE3PnXafdMWCw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 188F11801EB for ; Sun, 2 Feb 2025 13:33:01 +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=-2.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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, 2 Feb 2025 13:33:00 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43625c4a50dso24052355e9.0 for ; Sun, 02 Feb 2025 05:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738503346; x=1739108146; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=gJH+hWhFAB+EJZEPQzPDW6OmV1YJNarjaecQeCiDz4E=; b=i4fQ2B+wvsXJ5FDZPsK8e8jttsznOGd+rZMmlI3h94ccxpej0weGsR5bwU0MF9X1kw ZpwlcDaYrtm+XJTnPm7JJPo9ELuRM2JPwZXo1SFHXyNySoyKqKG6fH1hZ6z55PpwxD/K 5omJcaUbwoOqYSn0sgjhs18tFuPFXL7RykJaSRZj43lpTJC2HBUYnqU5eulwIuCt/OMr 3de9s+4U4eXH7aTDF3P0nApnOoHI5Q7unrOwQppORnEoeb9Ncvtkll4Sca2F73loq9OE PDczVL2wPpXtmG0uWuSl2MHDHq9S5ohfy5Rp6fD0esDofTAyCWfVNOY1wb2bSXbU8G9Z 5inw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738503346; x=1739108146; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gJH+hWhFAB+EJZEPQzPDW6OmV1YJNarjaecQeCiDz4E=; b=BI3CUd29XT+zk+y1w96dIwNo7N37CCKvBrldMpeVAoMaklC2zKNAaiYpu+gd2EgVZp x0xWYMiBj7k4MZ0Zshgd6U7E/tJutP0yfuCtAJCndMCMoxAQcZ3nc0PWZetbppneSm/G isbDerKkZ5EXhqLbe2N/7hIPHr+V0naZHFwxXNWMqGgfT0d4jSYG2LONoVu49wbf9vGQ vLyw9IX8GsQy8BZ/Qa/vJemM5xvJO8uLgy/jSftrHMqghKYWDWBCGHqLjQID1pp2rw4F yGMee4ZA6IOlBw1T8igCZgOYOXmgRf1+YqbhqTd7ePiXelHVOSAOwaeCupsqTq7340Hi VhhA== X-Gm-Message-State: AOJu0Yzx0H1VzGtc5BoU+92gl8mhGgjE1q7uf3VCJRjdalHqX0PA6rDW 80qO94X5Um0GSiq4aulBPt30SSC3XwJh5eITcn5kDC4PBDrTryoqRGfHCM1wBU1DxQ== X-Gm-Gg: ASbGnctd21v6Yh0y5eLse2IXSrCgdq+ghIbCADY1n7Ll06y58H4HTIvVth/AenOuEF6 vKS+zx2IZRUpsu3yVY4ht+b2ZrBGE4i2s/wh0Y/Q2sPsmckLIwdhZ9hyFW02d0EtjWRZiPA7x8F K6NpeffnmlkRGhdB8OA+IcfqIdFAOLlaqbEYoaxu4bFQwvuGmANcMOe4vvB39oJmDfP0kLg5fdR U2etqtRpX6KTqTFjno9oduFhkDB537vyex0NezqJWggxYcbfG09VVbx+Or7ebi3eSabzjkd+t78 rxZnfuKC2g3GXwL3evml4znE/McM0YvAzGkMuUB7mlTJ2GlVfhbFKaHoyQ== X-Google-Smtp-Source: AGHT+IF9hyA9iDJx9GCwMlMjfOcyrfUCUFtMZwCp+PJ3869FiCHw+fOuPHPD2+Kw4yA+qKhdjid6Ig== X-Received: by 2002:a05:600c:1e09:b0:434:f0df:a14 with SMTP id 5b1f17b1804b1-438e298c092mr110958795e9.2.1738503345666; Sun, 02 Feb 2025 05:35:45 -0800 (PST) Received: from smtpclient.apple (3611301-ch16866.twc1.net. [92.38.240.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1cf364sm9894415f8f.88.2025.02.02.05.35.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Feb 2025 05:35:45 -0800 (PST) X-Google-Original-From: Dmitry Derepko Message-ID: <878EED34-B28D-48FE-8EBE-5929841C12BD@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_077ED169-F7AC-45B4-96F7-21656C8908CC" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.113.1.2\)) Subject: [PHP-DEV] Re: Discussion: making continue and break into an expression Date: Sun, 2 Feb 2025 16:35:33 +0300 In-Reply-To: Cc: internals To: Robert Landers References: X-Mailer: Apple Mail (2.3826.400.113.1.2) From: xepozzd@gmail.com (Dmitry Derepko) --Apple-Mail=_077ED169-F7AC-45B4-96F7-21656C8908CC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 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? Hi!=20 I had similar idea to make `break`, `continue` and `return` be = expressions instead of statements to simplify almost the same cases as = Robert described above. Grammar corrections in the PR. https://github.com/php/php-src/pull/17647=20= Ilija pointed to memory leaking problems as well. Thinking about Ilija memory leaking case: new Foo + return 1 I think we may have a workaround here, by allowing all of these = constructions only available at some specific points: - as the statement now - $cond ? : ; - match ($v) { =E2=80=A6 =3D> } So it will deny such cases: - operand OPERATOR (1 + return; $cond && break; etc) It may prevent memory leaking problems. Isn=E2=80=99t it? I=E2=80=99m writing RFC: = https://wiki.php.net/rfc/return_break_continue_expressions=20 I=E2=80=99ll start a new discussion when it will be ready for it. ---------- Best regards, Dmitrii Derepko. @xepozz --Apple-Mail=_077ED169-F7AC-45B4-96F7-21656C8908CC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jan 25, 2024, at 12:16=E2=80=AFPM, Robert Landers = <landers.robert@gmail.com> wrote:

Hello = internals,

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?


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

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

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

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

So 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 start a new discussion when it will be ready for = it.


----------

Best = regards,
Dmitrii = Derepko.
@xepozz

= --Apple-Mail=_077ED169-F7AC-45B4-96F7-21656C8908CC--