Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328256

Summary: support multiple case expressions
Product: z_Archived Reporter: Henrik Lindberg <henrik.lindberg>
Component: b3Assignee: Project Inbox <b3.engine-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Henrik Lindberg CLA 2010-10-20 11:20:52 EDT
Since a case expression does not support "fall through", it becomes difficult to write a switch statement where the same expression/sequence of expressions is shared among cases. The case statement should take a list of expressions.

switch sExpr case expr1, expr2, ... : expr case ... endswitch

Semantics are that sExpr is evaluated and comared against the case expressions, the case with the first matching expression result is used. If sExpr is missing - the default sExpr value is TRUE and the selection works the same way.
Comment 1 Henrik Lindberg CLA 2010-10-20 22:20:37 EDT
Multiple case expressions are now supported.
Validation checks if an _ is used in a position other than the last and marks this as an error.
A quick fix is offered to move the _ last in the list.

Additional validation could be made - as it is quite meaningless to have additional expression if the last is ANY. (e.g. case 1, 2, _: ... - which is the same as just case _: ... ).