Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126280 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 095851A00BC for ; Tue, 4 Feb 2025 08:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738658516; bh=nSVLSFTKqXRxh0CibFajVepwOPSAOZsimDTJu3Ukmns=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=iDHw112G+KimU4zKoNNePu9BQ7LXUeGsGmSd3z+p0r7cd43qmZvuDbyv4jDo7WXZu bNU5N8biekh4uHUO97KjIE8F4COJixzCYKkGtZHyj0y54qmpfvbqur+xeDWRYmj3UZ rGeyxfxEqqJMIEzOv2AZLhAQYgN2lOZ/6oMPh/+uT65BrUtk7h3ArKK3HKGium5oO2 0lMjUS55OeqMhDjfKTrVUjXa6mHSxLGaAFXZwOuwG8LDecVL0Bfrbp9CMlGrF3VzRJ wNVtfZhZeILwmSAwTdkwJxFCWupAkyePKj6Epk6C+nQixkPSDJ9ij1Gky4DunKKX5z 0gGWOgoK3tBQA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C56C3180078 for ; Tue, 4 Feb 2025 08:41:55 +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=-1.2 required=5.0 tests=BAYES_50,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-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 ; Tue, 4 Feb 2025 08:41:55 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-385e06af753so2631576f8f.2 for ; Tue, 04 Feb 2025 00:44:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738658680; x=1739263480; 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=3V6JFIY6OlpzYyQdDEVE3xzjMxb9RPzcTZwPdempfIM=; b=D7lEpf5L0mvOEFR1QMo6z2MrkYGmmAFftAG9DFRJClCMtpcLh8Bhl9LNcIJSrDvYnV q5aMxoKN2WxlvHlOQZQQF4ufdWjRpE3/DmDkm9DeChaIli4KAY3xsoXSKkzrBIxJGg3o VT0PA+NlvKQ9Kb1uILd1XCjkKjC3stutLFuQptdt/4T3lgExcrnxU0cndh2Jy+KSWnlF s4opzxmw4K7TFD+lfymmczsGqlcCYCNjP3UK3V2BjTCTuIDg+zos1t5mBkbdVbRlX8G8 ynqgKZ2gZJrga0vFDpO0PrIf91jfPYP9jUtmQkmoECqLoySTo+/bp08PMIwReYRV/Z4N r/nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738658680; x=1739263480; 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=3V6JFIY6OlpzYyQdDEVE3xzjMxb9RPzcTZwPdempfIM=; b=JsQe3sa1WW4gq0j+RHodlrpZTxNJndf42T8A3TwlXgaADwKhg1Nt4Zl3+31cfQE0Jd nw508VFBvPm7OLTbL/+4jEJhRCVBW4GMl90e/Bw1Wrp3oi4W3rn4DIEShFSeN5XZybV8 aIiWpV6monokKbxCxND6TL0myz51axSsjzWQ8J7bmAc4aK3roHNUIbINBC5htrua5dd0 5nDy9JrwEQQPlzDr31jnF2WVQly6WCd/QNrZe286sG8vEpsG8m0STyuq4Kz6LIx+Zu3c 460viXdN4ldQeH/CMs4jNqUo387fLdRlb2p2s1tKsKLeJ/27QSeBPKwX7XI3IBpTaiYZ Ee6g== X-Forwarded-Encrypted: i=1; AJvYcCWBGLYSD3To2aibfjKu6J0ZwOwp/Q9vuqJcYYYe5fYnKyvPI7lSs2M2M8EgF+6FMN2eMhNJUnxjm9Y=@lists.php.net X-Gm-Message-State: AOJu0YwzAgSj7N1GscnpiMWKLxlDxBEalF3tKFJoAjocovcsgHk2h4CN 9RTb/HP7gElBZX0ySnXeui1nfS00SxWP77nJB//aFhb3PUzKCfhe X-Gm-Gg: ASbGncuOvYESDtIgoCWBMt9csRfr1s0Uiq59l7AQv4iKfaP2hDPdjVfqniTJTPSW22E /VCL45Qb6w5wvSbp+taH8d2Pmjn+SUb8cLqz4JrT9TLPcc8GEFB9kMDrtgysj+4aDEgLB2dE72m 1U8prmIAEcAlG72RnFfG1BYcMa4qh4w9Y9DNxXzM/oy2MBUmZEwFDJnOlNWjE+B7eA+A9JZChgd t5VcdR9tEKnVSYvu3m1KbsUMU1Np6mzzVIC9swGNWnLITUlpx98W8yVi09j2GMdHKzoPZ5O9K6t Nh+ZAWAQp01j/XUstUwhf5P+HA5kckWLmA== X-Google-Smtp-Source: AGHT+IEZNsNMdso2lfPUlrwgIXuVv/yEm/l+s97mYssu1WFkknYT5o/6l+AXKKqkXAHOhptXuvgywQ== X-Received: by 2002:a05:6000:1f87:b0:38a:624b:e37b with SMTP id ffacd0b85a97d-38c52097bbamr20991630f8f.53.1738658679652; Tue, 04 Feb 2025 00:44:39 -0800 (PST) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438e245efbcsm179098295e9.33.2025.02.04.00.44.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2025 00:44:38 -0800 (PST) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_FB01E150-BC31-4EF3-ADCA-9A9CFB32CE63" 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.300.87.4.3\)) Subject: Re: [PHP-DEV] Empty subject in match and switch constructions Date: Tue, 4 Feb 2025 09:44:27 +0100 In-Reply-To: <99F2F71B-8BBA-449B-9FB4-54B1B608BB0A@gmail.com> Cc: Larry Garfield , php internals To: Dmitry Derepko References: <2A357F88-BAF4-41DE-8646-6BBBF4EFF6F6@gmail.com> <99F2F71B-8BBA-449B-9FB4-54B1B608BB0A@gmail.com> X-Mailer: Apple Mail (2.3826.300.87.4.3) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_FB01E150-BC31-4EF3-ADCA-9A9CFB32CE63 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 4 f=C3=A9vr. 2025 =C3=A0 08:43, Dmitry Derepko = a =C3=A9crit : >=20 > Hi, Larry! >=20 >> On Feb 3, 2025, at 10:01=E2=80=AFAM, Larry Garfield = wrote: >>=20 >> On Sun, Feb 2, 2025, at 7:40 AM, Ilija Tovilo wrote: >>> Hi Dmitrii >>>=20 >>> On Sun, Feb 2, 2025 at 1:05=E2=80=AFPM Dmitry Derepko = wrote: >>>=20 >>> https://wiki.php.net/rfc/short-match >>> https://externals.io/message/112496 >>=20 >> Hi, author of that RFC here. Although there seemed to be interest = for it in the initial match() discussion, the stand-alone follow up was = met with a giant "meh", which is why I didn't pursue it further. I = would still be in favor of it, though, if it could get through = internals. I'm happy to have someone pick it up and run with it, or = collaborate on rebooting that RFC. (I'm pretty sure the patch for it = actually worked, at least it did at the time.) >>=20 >> --Larry Garfield >=20 >=20 > It looks funny that I=E2=80=99m following in your steps with the = RFC=E2=80=99s didn=E2=80=99t go through =F0=9F=98=83 >=20 > By the way, I=E2=80=99ve implemented empty match subject in a bit = different way: https://github.com/php/php-src/pull/17692 >=20 > About the RFC. What=E2=80=99s the way to re-activate it?=20 > Will you re-activate it? > Do I need to create a new one referencing to this one? > Can you share rights to edit the RFC and we can push it further = together? Hi, One issue to resolve is how to interpret: ```php $x =3D match { preg_match('/a/', 'a') =3D> "will it be matched ..." , default =3D> "... or not?" }; ``` knowing that preg_match(...) never returns `true`, but one of `0`, `1` = or `false`. More generally, how to deal with truthy-but-not-true values. I see three options: (a) check for strict equality with `true` (i.e. make `match {}` = equivalent to match(true) {}`). The `preg_match(...)` branch will never = be taken; (b) check for truthy values. The `preg_match(...)` branch will be taken = if the condition evaluates to 1; (c) mandate a boolean: The `preg_match(...)` branch will throw a runtime = error if the condition evaluates to 0 or 1; Personnally, I am against option (a) as it is confusing and would be a = source of bugs. =E2=80=94Claude --Apple-Mail=_FB01E150-BC31-4EF3-ADCA-9A9CFB32CE63 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 4 f=C3=A9vr. 2025 =C3=A0 08:43, Dmitry Derepko = <xepozzd@gmail.com> a =C3=A9crit :

Hi, = Larry!

On Feb 3, 2025, at 10:01=E2=80=AF= AM, Larry Garfield <larry@garfieldtech.com> wrote:

On Sun, = Feb 2, 2025, at 7:40 AM, Ilija Tovilo wrote:
Hi = Dmitrii

On Sun, Feb 2, 2025 at 1:05=E2=80=AFPM Dmitry Derepko = <xepozzd@gmail.com> = wrote:

https://wiki.php.net/rfc/short-match
https://externals.io= /message/112496

Hi, = author of that RFC here.  Although there seemed to be interest for = it in the initial match() discussion, the stand-alone follow up was met = with a giant "meh", which is why I didn't pursue it further.  I = would still be in favor of it, though, if it could get through = internals.  I'm happy to have someone pick it up and run with it, = or collaborate on rebooting that RFC.  (I'm pretty sure the patch = for it actually worked, at least it did at the time.)

--Larry = Garfield

It looks funny that I=E2=80=99m following in = your steps with the RFC=E2=80=99s didn=E2=80=99t go through = =F0=9F=98=83

By the way, I=E2=80=99ve implemented empty match subject in a bit = different way: https://github.com/php/= php-src/pull/17692

About the RFC. What=E2=80=99s the way to = re-activate it? 
Will you re-activate it?
Do I need to = create a new one referencing to this one?
Can you share rights to edit the RFC and we can = push it further = together?


Hi,
<= div>
One issue to resolve is how to = interpret:

```php
$x =3D match = {
    preg_match('/a/', 'a') =3D> "will it = be matched ..."
 , default =3D> "... or = not?"
};
```

knowing = that preg_match(...) never returns `true`, but one of `0`, `1` or = `false`. More generally, how to deal with truthy-but-not-true = values.

I see three = options:

(a) check for strict equality with = `true` (i.e. make `match {}` equivalent to match(true) {}`). The = `preg_match(...)` branch will never be taken;
(b) check for = truthy values. The `preg_match(...)` branch will be taken if the = condition evaluates to 1;
(c) mandate a boolean: The = `preg_match(...)` branch will throw a runtime error if the condition = evaluates to 0 or 1;

Personnally, I = am against option (a) as it is confusing and would be a source of = bugs.

=E2=80=94Claude

= --Apple-Mail=_FB01E150-BC31-4EF3-ADCA-9A9CFB32CE63--