From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: Expressive Case Statements (was: Software landmines) Date: 1998/09/02 Message-ID: <6si98q$fbo@sjx-ixn4.ix.netcom.com>#1/1 X-Deja-AN: 386985442 References: <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> <6r1glm$bvh$1@nnrp1.dejanews.com> <6r9f8h$jtm$1@nnrp1.dejanews.com> <6renh8$ga7$1@nnrp1.dejanews.com> <6rf59b$2ud$1@nnrp1.dejanews.com> <6rfra4$rul$1@nnrp1.dejanews.com> <35DBDD24.D003404D@calfp.co.uk> <6sbuod$fra$1@hirame.wwa.com> <35f51e53.48044143@ <904556531.666222@miso.it.uq.edu.au> <35EAEC47.164424A7@s054.aone.net.au> <6sgn8l$7aq$1@nnrp1.dejanews.com> <6sh487$lnq$1@nnrp1.dejanews.com> <6shit4$eaj@dfw-ixnews5.ix.netcom.com> Organization: ICGNetcom X-NETCOM-Date: Tue Sep 01 7:07:22 PM PDT 1998 Newsgroups: comp.lang.ada Date: 1998-09-01T19:07:22-07:00 List-Id: In article , eachus@spectre.mitre.org (Robert I. Eachus) wrote: as a solution to the problem I posed about truth tables, > type Truth_Table_3 is (False_False_False, False_False_True,... > True_True_True); > function To_TT3(Cond_1,Cond_2,Cond_3 : Boolean := False) > return Truth_Table_3; > > case To_TT3(Condition_1, Condition_2, Condition_3) is > when True_True_False => some_action_stub_statements; > when True_False_False => some_action_stub statements2; > when False_False_True => some_action_stub statements3; > when others => null; > end case; This comes close to what I am seeking. Now I need to read it over and see it I can make it more general. Thanks for your ideas, Robert. > Obviously you want the various truth table types in a package, >and you have several ways of writing the bodies of the conversion >functions. I prefer: > > function To_TT3(Cond_1,Cond_2,Cond_3 : Boolean := False) > return Truth_Table_3 is > begin > return Truth_Table_3'Val(Cond_1'Pos * 4 + Cond_2'Pos * 2 + Cond_3); > end To_TT3; > > I think I'd write a program to crank out the type declarations > though. I need to code this as a compilable example and see if I can generalize it. As it is, it appears to satisfy the special case of a three-valued table. The example coded in a functional language looked very good, but that is not Ada. Thanks again. Richard