Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126282 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 94D881A00BC for ; Tue, 4 Feb 2025 10:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738663708; bh=twtT8BnU1m9LSveEEOJLmLb0BMdg1YoooMb/wOwDPSE=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=HnGpuS2BfMAk2wSI6Ocm0/t9ZSDOfFxr7Y66mV4wJRQ1A3qL/kDygjThJPRFszgNe 5qnIwk2HerzzBqTyfsGPWqreSZ3nMjDpan4NgKsarGzFPmxi7or65rasxhnxJ/9pL+ dPMB8WnKPRgJJwELRUHOC6U8Ay+JpR0TAae9piqDpySgKkbHPJG/vNmdgAAa4e4qEo Q/CuoENFeJ0AsyoPlg/ANRKd2PWNvj9Dim9NVyPKBX8KARfSUkt9uaj4+4IdO4a97g d+UCwzBsEzOA6B/q2gCRq7G5K8ftxemckghCkIYGUL/6bUqrSVQX9NcV1ZCbgtV1sX twAgS4GbWreFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E40418006A for ; Tue, 4 Feb 2025 10:08:27 +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-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 10:08:27 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-38dae70f5d9so172748f8f.1 for ; Tue, 04 Feb 2025 02:11:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738663872; x=1739268672; 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=3SxErHUBOEo00uBUoHyANnDahjDL7F8/gYLNwBoeaU0=; b=kZHSyep+08g8RUXU64EpUzmHhwRWOMk3Jv4mcFZM/5nXNgd01EKQAP2KdF8NyoP89g grjkZB/9rgXWaR0LSmh7m1TYIaOxCd446Ry7YI93GMoRR460cSryRyZ3ktNxdMQHxe15 hucg0guBdtoAdgMQATMvuY8qkqSIzwBUkIWhpvhgAvGmuDD4VT0uglXRrpAMnx1UPoUZ /UqOiG+3F60/HW08QI9doIbWfR6WvE/yUjW18ukBB8k5CDOtF0Gbq+ubBuElDq0zrD2P aU8LEQnKwNGrgpbbJywrD65i2nJ0NJxA4rcX6iz69jH/sHLY2DKkIKMU0NRH/MxgHZKV DmkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738663872; x=1739268672; 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=3SxErHUBOEo00uBUoHyANnDahjDL7F8/gYLNwBoeaU0=; b=wZxAiHTJDZ/xo1laURsY6A4OqhO3ApohVwtbaKCpEJiBe9VObjsr2omvSe12ZFtQRM nkoaUxOxSxYjyVAVr/27lMtGSfd5plaMv6xb+VVw2h7lyt+Usa6gITa6e+cArmlBtIJv aOcaHnmJd6NR7Bazhs348b+RJBAn1A6Etg8VR/+1m8sDVbFgg1iN76+LgK95pa2GvlUW jpepypW2r4UyraGChwFmeZcKHfa38SeOVLoTC54DnkgFZsB7O4DGohOwCTI+aMAp24Ec /KTfzgUYp0rXI5mP/c+VRNeGjktXDVHHnwjf+LRavPBsShbYbZvQd/YmYcncMF3YEqY7 j2+A== X-Forwarded-Encrypted: i=1; AJvYcCXfkdt7rwKG4IubTyP2OOAzquJaR+B8aUkpIeyqghP67v3IAWnvrq9PckNQuoCGDuiIemTOSZ4Ztnw=@lists.php.net X-Gm-Message-State: AOJu0YxkAc91BAvmgb5Zhj+todQmlzjBTcDwLUd0frS2HNYUpjtOJrpa AglseWkTxQj49n2RTNw4n+uKWq2yO3xxaIV1mhR9yDifCc6XOjlU X-Gm-Gg: ASbGnctSSz313efMZTmG/vvV2nIHkf239jdUPFd3kwiJIB6PG/DCXMqiEH8yh+3U73x o71RaH1mwdbkMdGwbkBaZAbHf3t51bV3/eun4Q4zbPn28s8lnQoOeB3iVYIn44HBnFREQYvF+NT Dqo7o4SvdRKUmwe+SnSxUsl5Z4Yr7g1/MZzrxz4JEVCy+heoIfh48ziOKcYIss0CYBdVwJYe8r7 l6hiOo8UBFhAYaBMbFGVoRisEEJWWWD0tmYCSbr3pTkkaXXcn3/IFAbJBMxjijQLB7mXp1Nnzyt puBZy1bji0FPeNuKmvxISnMr9cdLJOlmFw== X-Google-Smtp-Source: AGHT+IG4C3CQJBAd/d9X6TCOrRItyy9xFV6IEZNA/yqzcZRpXOKjl3mqZjb3sY4IJMyeNxGdYzhy3g== X-Received: by 2002:a5d:59ad:0:b0:38c:1270:f966 with SMTP id ffacd0b85a97d-38c51949a9cmr18210467f8f.7.1738663870071; Tue, 04 Feb 2025 02:11:10 -0800 (PST) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c12191dsm15580574f8f.51.2025.02.04.02.11.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2025 02:11:09 -0800 (PST) Message-ID: <88F8E170-5AFB-46B3-BBBF-9430F00ECEFC@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_EAEBE000-4C55-4F5C-9C8D-C6218A36C608" 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 11:10:58 +0100 In-Reply-To: <296A94B1-3107-4DEB-8366-006BD73E63E2@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> <296A94B1-3107-4DEB-8366-006BD73E63E2@gmail.com> X-Mailer: Apple Mail (2.3826.300.87.4.3) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_EAEBE000-4C55-4F5C-9C8D-C6218A36C608 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 4 f=C3=A9vr. 2025 =C3=A0 10:34, Dmitry Derepko = a =C3=A9crit : >=20 > Hi, Claude! >=20 >> On Feb 4, 2025, at 11:44=E2=80=AFAM, Claude Pache = wrote: >>=20 >> Hi, >>=20 >> One issue to resolve is how to interpret: >>=20 >> ```php >> $x =3D match { >> preg_match('/a/', 'a') =3D> "will it be matched ..." >> , default =3D> "... or not?" >> }; >> ``` >>=20 >> =E2=80=94Claude >=20 > I wouldn=E2=80=99t discuss it there because the proposal is only about = short syntax. > So making =E2=80=9Cmatch=E2=80=9D work in different way is not a goal = for the change. >=20 > It must work as full form =E2=80=9Cmatch(true)=E2=80=9D: strict match, = which is "=3D=3D=3D=E2=80=9C. > If you=E2=80=99re going to use non-strict comparison check = =E2=80=9Cswitch=E2=80=9D operator: https://3v4l.org/tHkJu > Anyway, as for me it should be another thread. Thanks! Hi Dmitry, The issue absolutely belong to a thread discussing making =E2=80=9Cmatch = (true) {}=E2=80=9D equivalent to =E2=80=9Cmatch {}=E2=80=9D. It = doesn=E2=80=99t matter what is logical or simple, you have also think = about what is intuitive or, conversely, confusing. With `match (true) { $foo =3D> ... }`, it is clear you are comparing = $foo with the literal value `true`. With `match { $foo =3D> ... }`, it is not intuitive at all that you are = *not* just checking the condition $foo, but rather you are comparing = $foo with some default literal value. The difference matters. Therefore, I think it is a bad idea to make `match (true) { }` = equivalent to `match { }`. =E2=80=94Claude --Apple-Mail=_EAEBE000-4C55-4F5C-9C8D-C6218A36C608 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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

Hi, Claude!

On Feb 4, 2025, at 11:44=E2=80=AFA= M, Claude Pache <claude.pache@gmail.com> wrote:

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?"
};
```

=E2=80=94Claude

I = wouldn=E2=80=99t discuss it there because the proposal is only about = short syntax.
So making =E2=80=9Cmatch=E2=80=9D work in = different way is not a goal for the change.

It = must work as full form =E2=80=9Cmatch(true)=E2=80=9D: strict match, = which is "=3D=3D=3D=E2=80=9C.
If you=E2=80=99re going to use = non-strict comparison check =E2=80=9Cswitch=E2=80=9D operator: https://3v4l.org/tHkJu
Anywa= y, as for me it should be another thread. = Thanks!

Hi = Dmitry,

The issue absolutely belong to a thread = discussing making =E2=80=9Cmatch (true) {}=E2=80=9D equivalent to = =E2=80=9Cmatch {}=E2=80=9D. It doesn=E2=80=99t matter what is logical or = simple, you have also think about what is intuitive or, conversely, = confusing.

With `match (true) { $foo =3D> = ... }`, it is clear you are comparing  $foo with the literal value = `true`.

With `match { $foo =3D> ... }`, it = is not intuitive at all that you are *not* just checking the condition = $foo, but rather you are comparing $foo with some default literal value. = The difference matters.

Therefore, I think it = is a bad idea to make `match (true) { }` equivalent to `match { = }`.

=E2=80=94Claude


=
= --Apple-Mail=_EAEBE000-4C55-4F5C-9C8D-C6218A36C608--