home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!hri.com!noc.near.net!inmet!ryer
- From: ryer@inmet.camb.inmet.com (Mike Ryer)
- Newsgroups: comp.lang.ada
- Subject: Multi-way Case Statement
- Message-ID: <1992Dec15.173505.11693@inmet.camb.inmet.com>
- Date: 15 Dec 92 17:35:05 GMT
- Organization: Intermetrics Inc, Cambridge MA
- Lines: 29
-
- Here's another way to get the affect of multi-way case:
-
- type Three_Cases is (F_F_F, F_F_T, F_T_F, F_T_T,
- T_F_F, T_F_T, T_T_F, T_T_T);
-
- Truth_Table: constant array (Boolean, Boolean, Boolean) of Three_Cases :=
- (((F_F_F, F_F_T), (F_T_F, F_T_T)),
- ((T_F_F, T_F_T), (T_T_F, T_T_T)));
- begin
- . . .
-
- case Truth_Table(a>b, c/=d, e<f) is
- when F_T_F | F_T_T => ...
-
- when T_T_F | T_F_F => ...
-
- when T_T_T => ...
-
- when others => ...
-
- end case;
-
- Once you set up the two top declarations, you can code as many 3-way case
- statements as you like, without repeating them. I suspect that the ultimate
- generated code is the same as what you would get if it were a built-in
- language feature.
-
- Mike Ryer
- Intermetrics
-