From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 11 Dec 92 01:15:15 GMT From: darwin.sura.net!spool.mu.edu!umn.edu!The-Star.honeywell.com!saifr00.cfsat .honeywell.com!dunbar@gatech.edu (Mark Dunbar) Subject: Re: Suggestion for multivalue boolean case for 9X Message-ID: <1992Dec11.011515.2859@saifr00.cfsat.honeywell.com> List-Id: In article dnsurber@lescsse.jsc.nasa.gov (Dougl as N. Surber) writes: >How many times have you seen code like the following: > > if cond_1 then > if cond_2 > if cond_3 then > s_t_t_t; > else > s_t_t_f; > end if; > else > if cond_3 then > s_t_f_t; > else > s_t_f_f; > end if; > end if; [etc]... >I find this hard to read and even harder to maintain. Cond_3 appears >four times. That's a maintenance nightmare. A case statement that >worked on arrays of booleans would be a big improvement. Something like >the following: > > case (cond_1, cond_2, cond_3) is > when (true, true, true ) => > s_t_t_t; > when (true, true, false) => > s_t_t_f; > when (true, false, true ) => > s_t_f_t; > when (true, false, false) => > s_t_f_f; [etc]... > >Douglas Surber >Lockheed >Houston, TX > Using Ada83, instead of the nested if statement, one could do the following: if ( not Cond_1 ) and ( not Cond_2 ) and ( not Cond_3 ) then ... elsif ( not Cond_1 ) and ( not Cond_2 ) and ( Cond_3 ) then ... elsif ( not Cond_1 ) and ( Cond_2 ) and ( not Cond_3 ) then ... elsif ( not Cond_1 ) and ( Cond_2 ) and ( Cond_3 ) then ... elsif ( Cond_1 ) and ( not Cond_2 ) and ( not Cond_3 ) then ... etc. Although I do agree the case statement would be more elegant (sp?) and potentially faster if there were enough branches to cancel out the overhead of a case.