comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Expressive Case Statements (was: Software landmines)
Date: 1998/09/01
Date: 1998-09-01T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.4.02A.9809011607500.115-100000@shell5.ba.best.com> (raw)

On Tue, 1 Sep 1998, Richard D Riehle wrote:
>  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. 

Unfortunately, I don't COBOL, but I think I can read your case statement
below, and I wonder if the following, in Objective Caml, does the trick:
> 
>  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

let get_val b1 b2 b3 =  
	match (b1, b2, b3) with 
	| (true, true, false) ->
	perform1	
	| (true, false, false) ->
	perform2
	| (false, false, true) ->
	perform3
	| (_,_,_) ->  perform_default;;

I think ML style pattern matching is pretty powerful compared to Ada's,
and Prolog's even more so. 

> 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 ...

As I'm sure you know, you need to create mapping functions to an
enumerated type or something similar in order to use Ada's case statement. 
I don't think there is a general solution, you can't even use tags in 
case statements. Yeah, I prefer ML for its more powerful pattern matching,
but Ada has her charms too. I guess we Ada fans will have to do this by 
hand; we also have to do it by hand if we want to translate our close 
cousin language VHDL's case statement to Ada.

-- Brian






             reply	other threads:[~1998-09-01  0:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-01  0:00 Brian Rogoff [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-08-08  0:00 Why C++ is successful Jeffrey C. Dege
1998-08-10  0:00 ` Laurent GUERBY
1998-08-12  0:00   ` Andy Ward
1998-08-14  0:00     ` Robert Dewar
1998-08-14  0:00       ` Software landmines (was: Why C++ is successful) dennison
1998-08-16  0:00         ` Robert Dewar
1998-08-17  0:00           ` dennison
1998-08-19  0:00             ` ell
1998-08-19  0:00               ` adam
1998-08-19  0:00                 ` Dan Higdon
1998-08-20  0:00                   ` adam
1998-08-20  0:00                     ` Software landmines (loops) Nick Leaton
1998-08-30  0:00                       ` Matthew Heaney
1998-08-30  0:00                         ` Robert Martin
1998-08-31  0:00                           ` Matthew Heaney
     [not found]                           ` <35f51e53.48044143@ <m3af4mq7f4.fsf@mheaney.ni.net>
1998-08-31  0:00                             ` Andrew Hussey
1998-08-31  0:00                               ` Matthew Heaney
1998-09-01  0:00                                 ` Loryn Jenkins
1998-09-01  0:00                                   ` Matthew Heaney
1998-09-01  0:00                                     ` dewarr
1998-09-01  0:00                                       ` Optimizations (was: Software landmines (loops)) dennison
1998-09-01  0:00                                         ` Expressive Case Statements (was: Software landmines) Richard D Riehle
1998-09-01  0:00                                           ` Robert I. Eachus
1998-09-02  0:00                                             ` Richard D Riehle
1998-09-02  0:00                                               ` Robert I. Eachus
1998-09-02  0:00                                             ` Dr Richard A. O'Keefe
1998-09-02  0:00                                               ` Matthew Heaney
1998-09-02  0:00                                               ` Robert I. Eachus
1998-09-04  0:00                                                 ` Al Christians
1998-09-02  0:00                                               ` Richard D Riehle
1998-09-03  0:00                                                 ` Dale Stanbrough
1998-09-04  0:00                                                 ` Al Christians
1998-09-05  0:00                                                   ` Tom Moran
1998-09-01  0:00                                           ` Tucker Taft
1998-09-02  0:00                                             ` Richard D Riehle
1998-09-02  0:00                                           ` Tom Moran
1998-09-02  0:00                                           ` Tom Moran
1998-09-02  0:00                                             ` Matthew Heaney
1998-09-02  0:00                                             ` Richard D Riehle
1998-09-02  0:00                                               ` Tom Moran
1998-09-03  0:00                                                 ` Richard D Riehle
1998-09-03  0:00                           ` Fergus Henderson
     [not found] ` <35f51e53.48044143@ <m3af4mq7f4 <35F09429.1A7CD250@easystreet.com>
1998-09-07  0:00   ` Michael F Brenner
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox