Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107584 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85359 invoked from network); 20 Oct 2019 09:16:09 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 20 Oct 2019 09:16:09 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id D33522D1F87 for ; Sun, 20 Oct 2019 00:01:29 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15716 95.128.32.0/21 X-Spam-Virus: No Received: from mx.kolabnow.com (mx.kolabnow.com [95.128.36.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Sun, 20 Oct 2019 00:01:28 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTP id 0F867406FB for ; Sun, 20 Oct 2019 09:01:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-language:content-type :content-type:in-reply-to:mime-version:date:date:message-id:from :from:references:subject:subject:received:received:received; s= dkim20160331; t=1571554886; x=1573369287; bh=SOrXRUmPpC39pAaGSWi ggFQjz2uvkvFKGWkRq8i3DWI=; b=xUaU5p7PY6hOf256X0/owVrq/6XP2QiP9cP rYpgSoUXECzkT401qDQ36fzVwvIbGxd+FuHgPz74xvZev441GuC6cjddAEdscuyk YTVgiEr7eCTp0IVE63DvujMOEFSLewEwfpz8/q+S2sJf1d0JofOosRqr9U28mqfY W+LIfGQk1QUfbMWp1os4BWfV5OnQzYtOyTcvinihmPlXWPHXDSVy0Uts7L+DkutE T2RBhq3uJuQNIT2zlIBQbcgbzFQ5l2fWsse6djx5BZTQOIe+mlvgp8TQ0bGS8R6N eHGoHBwU6lW8iWQt1jeiPrpSOMTaYQ1GxKwoH2CnMNknLgJQ/xQf4iKz557cmzHA tsMpiqnwmUdZsL+0ltruVnaIwscL33VLz9YahFFG6JZMlr+w8kOhvbjvXpCHhyE7 7vVnh1LVBH9oArpeCuu71Tll/eTNhpw9Wgv+geUlG5Y0AZgsvwnYdvAQTBx9x2de 8DMAKZ1xYkremCw/on3rC6YrKa2fl6cZibcjo/T+1KMguan5lRfYWFiMq9ffutZY 6c/6tWiclNf+m6GLyq9ObGZyQQee8BJyhutqN7IOWBeqK8kS4fQZypxngR9gEh3l 3ibAGD3N1q+ei2Has/sSKbI4jxRCN1BTv7Gv4MKkwuSeD3dsxfU/bgUGNg3f+UKP gtnEc+SQ= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out003.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yxqi3CzucrnM for ; Sun, 20 Oct 2019 09:01:26 +0200 (CEST) Received: from int-mx002.mykolab.com (unknown [10.9.13.2]) by ext-mx-out003.mykolab.com (Postfix) with ESMTPS id 508B940589 for ; Sun, 20 Oct 2019 09:01:26 +0200 (CEST) Received: from ext-subm003.mykolab.com (unknown [10.9.6.3]) by int-mx002.mykolab.com (Postfix) with ESMTPS id EBA24144B for ; Sun, 20 Oct 2019 09:01:25 +0200 (CEST) To: internals@lists.php.net References: <929062F1-E83F-4D81-B2C6-3916B744E101@newclarity.net> <5da8e051.1c69fb81.b05ef.ef7dSMTPIN_ADDED_MISSING@mx.google.com> <11ada3a9-ee9a-1364-7a06-96d1533d544b@alec.pl> <1E765C07-5503-4A23-949D-F2D79E9C2164@newclarity.net> Openpgp: preference=signencrypt Message-ID: <14d25a21-f2ec-ef80-f134-00fa8071f54b@alec.pl> Date: Sun, 20 Oct 2019 09:01:22 +0200 MIME-Version: 1.0 In-Reply-To: <1E765C07-5503-4A23-949D-F2D79E9C2164@newclarity.net> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Envelope-From: Subject: Re: [PHP-DEV] Adding explicit intent for SWITCH/CASE fall through? From: alec@alec.pl ("A.L.E.C") On 10/20/19 2:39 AM, Mike Schinkel wrote: >> case X: >> if (something) { >> fallthrough; >> } >> something-else; >> break; >> case Y: .... > > Interesting. > > What would you expect this to do? It is not intuitively obvious to me. Directly jump to the next `case` (as `goto` would do). Also, fallthrough probably shouldn't be just a no-op, it should be jump. Consider this code case X: fallthrough; break; case Y: It should be clear what would happen in such cases. >> Then, don't we need a way to jump outside of the whole switch statement? Ah, there's `goto` already. So, maybe extend `goto` somehow? > > Is that not what `break` is for? Right. I was too much on throwing new ideas that I missed that some are already implemented ;). The point was that fallthrough with these added functionality mentioned above would be very close to `goto`. On the other hand: case X: goto next; // or goto case; ? case Y: sounds worse than: case X: fallthrough; case Y: or case X: pass; case Y: > The fact a potential feature is a no-op does not discredit it for me; instead I focus on the benefits the proposed feature can provide. > > In this case the benefits would be to alerting developer when they accidentally omit instructions to PHP of their intentions. And that seems to me to be something (almost?) everyone would want to see embraced? Clearly* PHPStan and many Linux developers would like the same[1][2]. Maybe if it was a feature (keyword) that could be useful in other places not only in switch... I proposed "pass" because it might have some uses out of switch (nothing comes to my mind, though right now) and because "fallthrough" is kinda hard word for non-native speakers. "pass" exists in Python. https://docs.python.org/2.0/ref/pass.html >> It might be not useful enough to justify a BC break. That was my intention, to find more value in a new feature to justify BC break. -- Aleksander 'A.L.E.C' Machniak Kolab Groupware Developer [http://kolab.org] Roundcube Webmail Developer [http://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com