[swift-evolution] Proposal: Remove the "fallthrough" keyword
Rainer Brockerhoff
rainer at brockerhoff.net
Sun Dec 6 11:32:46 CST 2015
On 12/5/15 22:02, swift-evolution-request at swift.org wrote:
> Date: Sat, 05 Dec 2015 18:23:28 -0500
> From: Steve Canon <scanon at apple.com>
> To: John McCall <rjmccall at apple.com>
> Message-ID: <CA6BFF82-A212-41B6-8104-A0527E84D31C at apple.com>
>
> Very much thinking out loud and not really the implications, I wonder if we might just use "continue" instead of "reswitch".
>
> I very much like specifying what case to fall through into, no matter how we spell it.
It's somewhat funny seeing you guys all avoiding the word "goto"... :-)
Hey, it's just a unconditional branch!
Now seriously, in a past incarnation I used C in very resource-limited
contexts (both in execution time and code size) and goto-ing around
inside a switch statement was often the only solution.
Not that porting Swift to a Raspberry Zero should be a short-term goal,
but if the current "fallthrough" stays in whatever incarnation, I'd be
happy.
Typing this in reminded me of a possible way to allow common code to be
executed at the end of some cases, but not others: before the switch,
set up a closure (or an array or dict of closures, whatever) and call
that as the case's last statement; no doubt you-all would have
suggestions about properly scoping such a thing.
--
Rainer Brockerhoff <rainer at brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://brockerhoff.net/blog/
More information about the swift-evolution
mailing list