[switch] Further unification on switch
brian.goetz at oracle.com
Fri Apr 20 14:32:11 UTC 2018
> Here's a fun statistic from Google's codebase. We analyzed every
> hand-written switch statement in our depot. Only /2.4%/ of them used
> fall-through. The number in the real world might be somewhat higher
> (?), but we know it to be quite small. Yet, the things about switch
> that have been weird, confusing, or dangerous all stem from that
> fall-through model that such a tiny fraction need -- how sad!
We did a similar (though less methodical) survey of switches in
java.base, and found a higher number, but that's to be expected because
(a) its an old code base that is closer to the C influences and (b) it
contains a lot of low-level code for parsing packets and such. But my
general conclusion is the same.
More information about the amber-spec-observers