Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109901 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69531 invoked from network); 29 Apr 2020 02:46:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Apr 2020 02:46:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B9651804E0 for ; Tue, 28 Apr 2020 18:20:13 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 28 Apr 2020 18:20:12 -0700 (PDT) Received: by mail-il1-f180.google.com with SMTP id c16so874094ilr.3 for ; Tue, 28 Apr 2020 18:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=4smUoK8lGJTXJMWVCNEixJoc0OuRhmI4c6FpY0evG1A=; b=WgCvV3i+vBsjp56m5oBnU2mGgluCkDzL6+sRUunncFUHtAnP8g0sgxWp8vAidoRwu1 ecJG6QO61CptAPxSmUPE4P1y1YXHphES3Jh7P8L9ZiLMzBmZ2EyDVZpKGFeVoajOiP0X Pfljj1QgEuWWuONE1+M/yIFdM7ADCaUBJaNjs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=4smUoK8lGJTXJMWVCNEixJoc0OuRhmI4c6FpY0evG1A=; b=SKVEUHmXWoK8a6PyFz0OUIABcsSfc/I/rAeTPnjzMMvkvLFU8t2qR2oAc80qGG8VbF N1IzYB7rZdzOyPbrshHm0fTGNLuRoI3G55uhJngChsaQfOfLPGR6MuuPB8zRRZbv5Ixw eApf0WOPZZvL4HouxPzV3UsXh0M6LHgDt1GCoyygn3RUtakjD23259xCL3AO5PwC/iYD Ngog5vw3kQM2bZirNPHF7cQjUQns36C2LLWCqLQWJRDY2twiR/08oSGyNm9A+ltqhIuo h4yhUtLwvdJvYAh7geqgnZYvrj7dHGbxM+/X9ia/1JQJr48MlDMDSYYeIDt/YlMr9aJ1 0xSg== X-Gm-Message-State: AGi0PuZmOtMM135QURSdbGtHA6N2a2GVjX3p8VQou42T/H0BDjgfB4Zq PohbtC2wMt1fw4MUUokaAEsWOYw8MgnZ4P6l5CZyzA== X-Google-Smtp-Source: APiQypK923dtXfqNsnXFaYodb1r0d7bNmn33cxFP/ZAdZ24tkN0c1zPG8MH+ZYerHC93eI6StO4ql92WQypybLMUBxo= X-Received: by 2002:a92:5dc4:: with SMTP id e65mr29447538ilg.161.1588123209677; Tue, 28 Apr 2020 18:20:09 -0700 (PDT) MIME-Version: 1.0 References: <5ea6e4b0.1c69fb81.cf3ee.2bbfSMTPIN_ADDED_MISSING@mx.google.com> <969c6150-a084-48c0-ae8f-b8043dce321d@www.fastmail.com> In-Reply-To: Reply-To: Levi Morrison Date: Tue, 28 Apr 2020 19:19:58 -0600 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] match expression From: internals@lists.php.net ("Levi Morrison via internals") On Tue, Apr 28, 2020 at 6:58 PM Larry Garfield wro= te: > > On Tue, Apr 28, 2020, at 7:37 PM, Levi Morrison via internals wrote: > > > One issue that was discussed a few weeks ago, and led to the current = syntax, was too many variations within the switch syntax; of course, trying= to do it all in one syntax is perpetuating that problem. However, I think= Rowan has suggested a syntax that may be sufficiently self-documenting. T= o wit, independent of rustmatch (above): > > > > > > switch ($foo) { > > > case 1: { > > > Many statements here. > > > } > > > case 2: { > > > Many statements here. > > > } > > > } > > > > > > The curly braces are already understood by most PHPers to mean "a blo= ck of statements", and so it's a logical jump in this case. As Rowan sugge= sts, the {} imply a break. To keep it simple we should probably not allow = mixing and matching in a single switch. Either list-style (break required)= or {}-style (break implied). > > > > > > That handles break; > > > > Sadly, it doesn't. That code is valid today: > > > > > $foo =3D 1; > > switch ($foo) { > > case 1: { > > echo "1\n"; > > } > > case 2: { > > echo "2\n"; > > } > > } > > ?> > > > > Which outputs: > > 1 > > 2 > > ... Well, crap. It just can't be easy, can it... > > Would it be too context-sensitive to have the {} version only work in str= ict switch? > > Or for that matter... is anyone actually using that syntax in the wild, o= r is it hypothetical? Viz, if the behavior of that changed in 8.0 (a major= release), would that even break anything? Even 7.4 has a couple of "the b= ehavior changed but seriously who was using this anyway?" points in it. Co= uld we get away with just changing it for 8.0? > > I'm not sure if Nikita's "check the top 1000" script could handle somethi= ng that subtle. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php I am confident it was used in a former employer's codebase, which is how I immediately knew it was valid. My memory is too fuzzy to remember anything more than it was used, unfortunately.