home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3693 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.1 KB

  1. Path: sparky!uunet!usc!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!hri.com!noc.near.net!inmet!ryer
  2. From: ryer@inmet.camb.inmet.com (Mike Ryer)
  3. Newsgroups: comp.lang.ada
  4. Subject: Multi-way Case Statement
  5. Message-ID: <1992Dec15.173505.11693@inmet.camb.inmet.com>
  6. Date: 15 Dec 92 17:35:05 GMT
  7. Organization: Intermetrics Inc, Cambridge MA
  8. Lines: 29
  9.  
  10. Here's another way to get the affect of multi-way case:
  11.  
  12.   type Three_Cases is (F_F_F, F_F_T, F_T_F, F_T_T, 
  13.                        T_F_F, T_F_T, T_T_F, T_T_T);
  14.  
  15.   Truth_Table: constant array (Boolean, Boolean, Boolean) of Three_Cases := 
  16.        (((F_F_F, F_F_T), (F_T_F, F_T_T)), 
  17.         ((T_F_F, T_F_T), (T_T_F, T_T_T)));
  18. begin
  19.     . . .
  20.  
  21.   case Truth_Table(a>b, c/=d, e<f) is
  22.     when F_T_F | F_T_T => ...
  23.  
  24.     when T_T_F | T_F_F => ...
  25.  
  26.     when T_T_T => ...
  27.  
  28.     when others => ...
  29.  
  30.   end case;
  31.  
  32. Once you set up the two top declarations, you can code as many 3-way case
  33. statements as you like, without repeating them.  I suspect that the ultimate
  34. generated code is the same as what you would get if it were a built-in
  35. language feature.
  36.  
  37. Mike Ryer
  38. Intermetrics
  39.