Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328256 - support multiple case expressions
Summary: support multiple case expressions
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: b3 (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-20 11:20 EDT by Henrik Lindberg CLA
Modified: 2017-09-13 11:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 _: ... ).