Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107582 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24201 invoked from network); 20 Oct 2019 02:54:26 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 20 Oct 2019 02:54:26 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 2EB6B2CE9F3 for ; Sat, 19 Oct 2019 17:39:42 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-yw1-xc33.google.com (mail-yw1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) (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 ; Sat, 19 Oct 2019 17:39:41 -0700 (PDT) Received: by mail-yw1-xc33.google.com with SMTP id 129so3596894ywb.8 for ; Sat, 19 Oct 2019 17:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=QqfOLIYgsaEa2VauidBQDEdqtBVN1ez5wdJmknTeTjo=; b=SUh3eQ5xzn65hB7MdGJ4Bnujpk9SZAm3rxJ93TBoRL6RTVSdkVktc8+EJpNFUxCG6g 5EeQAnd8vtBJTw6E0r13wZDyhFb6XXftK8cnHfLSlTA7ggvhZBtnKqZSA5ZaQRX6strg 8OXT6VuWOiCuu7kexjFuUSOT08gv+FchzyF4SQAyGLS2SiqLNqrnKKnhxz7/w3f3gB06 uvE1fRRli/TM651BlH0kpguZajgISOYNYB/e7V2298YFefZv/jPLXHbcEaqYbJBy6SMs S865Zdc9bYASVo2BUIwkYPABRDQlIiYOhX9oYGvas0w7sIQa1cbtcA564ey4NF0z8ncZ 9KrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=QqfOLIYgsaEa2VauidBQDEdqtBVN1ez5wdJmknTeTjo=; b=giR+uMmpMVdiqI4VMOHkSQeG+b68HgLnlzk3mxOt1eoVR/AZoQMmzTrN5x8LaUEIAX EqCvxgWwW0u3qjR7mZ2yKdI2KxQPm9HDHi+qqUa6Zqu6wlqGFm8Murw73mo1XFexBsLH SUd6o7n2RrZGZUFQgHPLo6FqmAACVnlF3zXmx+RGBCSFtsiXE6FUqpFaQGdTZIMCApS1 Npf1slAzjVX8QQ9ewLLgqDhy2YX0w0as+15kLoOr1vVjZFZ6yrzE0F1OPWdqc9TFinUz svVjl8KXED/OBC1kNk/F5o5htGz+aesfkUvFZPSveap3feWiE5U1SkXLoftv96jD2RCq cKSA== X-Gm-Message-State: APjAAAXGEClDkPISXIHjtWfbcnFWVOSrceq2dSlpS9qroT0QQHyT27PE 2hmMUZEjyeL0v9eDk9isIIMy+QReT/ZRGQ== X-Google-Smtp-Source: APXvYqz3AnheFxD6eNYhQTLUOv5J+hhCxbXRV/IVlfuWNhkCa+oVb4zd5Enj+472cU7rTkB0IajrwQ== X-Received: by 2002:a81:36d4:: with SMTP id d203mr12359097ywa.313.1571531980920; Sat, 19 Oct 2019 17:39:40 -0700 (PDT) Received: from ?IPv6:2601:c0:c67f:e34e:4135:43c4:3532:a219? ([2601:c0:c67f:e34e:4135:43c4:3532:a219]) by smtp.gmail.com with ESMTPSA id a64sm2448311ywe.92.2019.10.19.17.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Oct 2019 17:39:38 -0700 (PDT) Message-ID: <1E765C07-5503-4A23-949D-F2D79E9C2164@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_5364A955-1454-46E8-8AA0-D7AB4F52B5B5" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Sat, 19 Oct 2019 20:39:38 -0400 In-Reply-To: <11ada3a9-ee9a-1364-7a06-96d1533d544b@alec.pl> Cc: internals@lists.php.net To: "A.L.E.C" References: <929062F1-E83F-4D81-B2C6-3916B744E101@newclarity.net> <5da8e051.1c69fb81.b05ef.ef7dSMTPIN_ADDED_MISSING@mx.google.com> <11ada3a9-ee9a-1364-7a06-96d1533d544b@alec.pl> X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] Adding explicit intent for SWITCH/CASE fall through? From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_5364A955-1454-46E8-8AA0-D7AB4F52B5B5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Oct 19, 2019, at 3:05 AM, A.L.E.C wrote: > Imo, this would make more sense if fallthrough did something more, = e.g. allowing >=20 > case X: > if (something) { > fallthrough; > } > something-else; > break; > case Y: .... Interesting.=20 What would you expect this to do? It is not intuitively obvious to me. > Going this way we could imagine that `fallthrough N` could allow = skipping N following > `case`s While I can see that as possible, I cannot think of any use-cases where = I would even want to use it. Can you? Either way, I doubt I would never use it as IMO it could make for some = very fragile code. =20 > and `fallthrough default` jumping to the default section. Now I do like this, because it does not seem fragile to me and I could = see it having some use-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? > Adding a no-op keyword does not make much sense to me. There are many no-op keywords already in PHP, such as typehints; they = provide information to the PHP so it knows when to throw warnings and = errors. 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.=20 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]. > It might be not useful enough to justify a BC break.=20 True, that is a concern. Not yet having experience working on PHP's parser I do not know how it = is configured nor what about the design of PHP requires keywords unable = to be used as constants, class names, function or method names. I know = this is a tangent but that seems like a requirement designed to simplify = the parser maybe, and not because of any logical requirement. So I = assume whatever word was used for this would also have to be a reserved = keyword? Or not? Can someone who knows why the parser requires reserve words speak to = why?=20 If it would have to be a BC break, then maybe we could overload break = with `BREAK NEXT` instead of `FALLTHROUGH` to achieve the same goal? Or = `CONTINUE NEXT`? I will say the term `FALLTHROUGH` is used in GoLang and the GCC = compiler[2] so it might be the best for familiarity reasons, but BC = might override that concern. Does anyone know how to quickly scan the top PHP projects to see how = many would break if `FALLTHROUGH` were used? I know I could write a = program to do it, but I have so many other programs to write... -Mike * Props to Bishop Bettini for these links [1] https://github.com/phan/phan/issues/2550 = [2] https://lwn.net/Articles/794944/ --Apple-Mail=_5364A955-1454-46E8-8AA0-D7AB4F52B5B5--