expression switch vs. procedural switch
guy.steele at oracle.com
Wed Mar 14 17:57:06 UTC 2018
> On Mar 14, 2018, at 12:45 PM, forax at univ-mlv.fr wrote:
> De: "Guy Steele" <guy.steele at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Kevin Bourrillion" <kevinb at google.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Mercredi 14 Mars 2018 17:12:34
> Objet: Re: expression switch vs. procedural switch
> On Mar 14, 2018, at 12:16 PM, Remi Forax <forax at univ-mlv.fr <mailto:forax at univ-mlv.fr>> wrote:
> . . .
> yes, but it's what i detest the most about C++, everyone has its own dialect.
> What is the solution? A style requirement that every programmer use every feature in the language at least once in any program? (I have known programmers like that, and their code was not necessarily any easier to read.)
> Do not introduce a feature in the language which is used once every year is a good start.
> Do not add a solution to solve the corner^2 case (the corner case of a corner case as Brian call it) in the language.
These are good answers to my question, thanks!
> I am sympathetic to your feeling about this, but have no idea how to encourage it or enforce it. You really can’t prevent a programmer, or group of programmers, from sticking to a subset that makes them happy.
> on the Human aspect of programming, publish an official language guideline and provides tools that enforce it like Google does with Java or golang (with go-fmt).
I agree that common guidelines are a good thing.
But you still can’t prevent programmers from choosing their own “happy subsets” of even the official guideline.
Simple example: suppose I choose, as my own special discipline (which I have sometimes used) never to use `break` to break out of a `for` or `while` loop, but instead insist on providing a label and using `break label;`. The rationale is that whenever I see a plain `break` in my code, I always know it’s for a `switch` statement.
If you agree with this idea, then I win: I get to use my happy subset.
If you disagree, then I really win: it demonstrates that you and I would choose different happy subsets! :-) :-) :-)
(Don’t mind me; I’m feeling puckish today.)
More information about the amber-spec-observers