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/01 Message-ID: <6shit4$eaj@dfw-ixnews5.ix.netcom.com>#1/1 X-Deja-AN: 386888840 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> Organization: ICGNetcom X-NETCOM-Date: Tue Sep 01 2:45:40 PM CDT 1998 Newsgroups: comp.lang.ada Date: 1998-09-01T14:45:40-05:00 List-Id: In article <6sh487$lnq$1@nnrp1.dejanews.com>, dennison@telepath.com wrote: >Being one of those goto-phobes as well a big fan of case statements, this >subject interests me. I assumed the relatively strict rules on case statement >predicates were specifically formulated so that they could be implemented as >jump-tables. Is that not the case? Is there anything that I can do to my case >statements to help the compiler out a bit? I realize this was supposed to be about optimizations. But this is the year of changing the subject what with tails wagging dogs, etc. Ted's mention of "case statements" reminds me of a problem with which I have been struggling for quite a while; one for which I finally cry, "Help!" There is a language called COBOL in which the ANSI 1995 standard introduced a fascinating construct called the EVALUATE statement. It is the most powerful form of a case statement I have seen in any programming language. More powerful than Ada. More powerful than Eiffel. More powerful than C++ or Java. One of the forms the EVALUATE statement (there are several options), allows the programmer to directly represent a decision-table for a set of conditions with syntax such as, EVALUATE condition-1 ALSO condition-2 ALSO condition-3 WHEN TRUE ALSO TRUE ALSO FALSE PERFORM some action-stub statements END-PERFORM WHEN TRUE ALSO FALSE ALSO FALSE PERFORM some action-stub statements END-PERFORM WHEN FALSE ALSO FALSE ALSO TRUE PERFORM some action-stub statements END-PERFORM END-EVALUATE In business data process software, such as banking and insurance, the decision table is useful for representing complex sets of conditions and their corresponding actions. In military command and control systems we also see these kinds of complex condition sets. It is certainly easy to represent any set of conditions with a sequence of if ... elsif statements but I am seeking something else. What I have been trying to accomplish is some generalized algorithm in Ada that allows me to design a package that approximates the power of the EVALUATE statement in COBOL. Some of the new features of Ada 95 such as generic formal package parameters, access to subprogram, etc. have helped a little, but ... .... so far, I am not satisfied with the result of my own efforts. I am curious if anyone else has approached the problem of decision tables in this way. Is there a generalized solution in Ada with the expressive power of the COBOL EVALUATE? This would seem to be such a useful reusable component that I would be surprised if no one has done it yet. Richard Riehle richard@adaworks.com http://www.adaworks.com