Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102274 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62184 invoked from network); 15 Jun 2018 12:19:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2018 12:19:19 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain brzuchalski.com from 188.165.245.118 cause and error) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:49541] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/13-29356-CBEA32B5 for ; Fri, 15 Jun 2018 08:19:08 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 9C08F298423A for ; Fri, 15 Jun 2018 14:19:04 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UylHnm_0C2zk for ; Fri, 15 Jun 2018 14:18:59 +0200 (CEST) Received: from mail-ot0-f182.google.com (unknown [74.125.82.182]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 3925C2984236 for ; Fri, 15 Jun 2018 14:18:59 +0200 (CEST) Received: by mail-ot0-f182.google.com with SMTP id w13-v6so10738672ote.11 for ; Fri, 15 Jun 2018 05:18:59 -0700 (PDT) X-Gm-Message-State: APt69E3rtPolbor2tConKCQoVrmlrGYA/rq02+5yJmvKLCRsWApJLk3n vpJKyWEPQIfYA1P3efwuFombLvzijofkecaS5qU= X-Google-Smtp-Source: ADUXVKJvbIXYUfbwlY8G+wRx1G5GcAoMR3r9+aN6J1WjtUc6/g03j5WzTTGB+ssHXDj+b8rF7qAKowV3Cz5yrfncDNg= X-Received: by 2002:a9d:2141:: with SMTP id l1-v6mr777134otd.36.1529065138217; Fri, 15 Jun 2018 05:18:58 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:27c5:0:0:0:0:0 with HTTP; Fri, 15 Jun 2018 05:18:57 -0700 (PDT) In-Reply-To: <048ed6c7-2bf5-537a-759b-79fd1767e65d@gmx.de> References: <82788099-3fba-282a-8d28-68b0ea3276be@php.net> <048ed6c7-2bf5-537a-759b-79fd1767e65d@gmx.de> Date: Fri, 15 Jun 2018 14:18:57 +0200 X-Gmail-Original-Message-ID: Message-ID: To: "Christoph M. Becker" Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000066e97f056ead38d1" Subject: Re: [PHP-DEV] Strict switch statements From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --00000000000066e97f056ead38d1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2018-06-15 11:44 GMT+02:00 Christoph M. Becker : > On 15.06.2018 at 08:36, Sebastian Bergmann wrote: > > > Am 14.06.2018 um 10:35 schrieb Nikita Popov: > > > >> It might make sense to introduce an entirely new "match" statement > >> that conforms a bit more with how switch-like strictures are > >> implemented nowadays. That is, something like > >> > >> match ($expr) { > >> "foo" =3D> {...}, > >> "bar" | "baz" =3D> {...}, > >> } > >> > >> or similar. > > > > Interesting. Can you provide a pointer to a language that has a match > > statement like that? > > This match statement (or would it be an expression?) could be regarded > as an extremly simplified syntactic variant of the case-of expression of > Standard ML[1]. > > Instead of the pipe operator we could use a comma to separate multiple > =E2=80=9Cpatterns=E2=80=9D. Using =E2=80=9Ccase=E2=80=9D instead of =E2= =80=9Cmatch=E2=80=9D appears to be something to > consider as well. > > [1] > , > section =E2=80=9CPattern Matching=E2=80=9D > > -- > Christoph M. Becker > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > It's just a thought but maybe providing a new declare directive like `declare(strict_comparison=3D1);` be easier for those who prefer stric= t everywhere? We have `declare(strict_types=3D1);` so we may have stricter declares also. Maybe someday it turns into a standard way of working with PHP and can get rid of declares without any code changes. This may result in all comparisons strict without type juggling and won't need any syntax changes at all. And it'll apply for switch,if,else,ifselse,for,while etc. in all comparisons. Or maybe `declare(no_type_juggling=3D1)` or smth like that. --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --00000000000066e97f056ead38d1--