[rules-dev] A note on the "switch" proposal for Drools 6.0

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jul 24 04:24:20 EDT 2012


The switch statement as we see it in C and Java is due to the classic
"multiway branch" based on a (single) discrete value. As K&R note (in
their book), "falling through" has an advantage: it permits more than
one case label in front of code to be executed alike for all values.
The disadvantage is the necessity of using "break" at the end of such
a statement sequence.

Other languages (Pascal, Modula, Ada,...) permit lists and ranges in
case labels: hence there is no necessity for "break", and case
branches are distinct alternatives.

If the "switch" in the current proposal for Drools 6.0 has no (or no
useful) interpretation of "falling through", then "break" should not
be necessary.

-W


More information about the rules-dev mailing list