comp.lang.ada
 help / color / mirror / Atom feed
* Re: Expressive Case Statements (was: Software landmines)
@ 1998-09-01  0:00 Brian Rogoff
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Rogoff @ 1998-09-01  0:00 UTC (permalink / 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






^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: Why C++ is successful
@ 1998-08-08  0:00 Jeffrey C. Dege
  1998-08-10  0:00 ` Laurent GUERBY
       [not found] ` <35f51e53.48044143@ <m3af4mq7f4 <35F09429.1A7CD250@easystreet.com>
  0 siblings, 2 replies; 23+ messages in thread
From: Jeffrey C. Dege @ 1998-08-08  0:00 UTC (permalink / raw)


On 8 Aug 1998 08:27:02 -0400, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>
>Undoubtedly at least *part* of the problem in using C is that people are not
>sufficiently aware of what can go wrong. Microsoft has a rather amazing
>book that pretends to be a book about software techniques, but in fact is
>little more than a set of perfectly standard coding procedures to avoid
>pitfalls in C. When I read it, I was surprised that professional C 
>programmers would find such a book useful, but the questions above are
>a reminder that you often people are not aware of the dangers. 

If you're talking about Steve McGuire's books, (Code Complete, Writing
Solid Code), I'm a professional C programmer, and I didn't find anything
in them that I hadn't been aware of for many years.

>I must
>say I worry about CS curriculums in which people are only getting exposed
>to C and C++ and hence simply don't register important language design
>principles (after all the idea that it is obviously a bad idea to allow
>pointers to local variables is a very old one, dating back at least to
>Pascal, which means coming up to 30 years.

I have to agree with the above.  A CS curriculumn should have some breadth
to it.  Exposure to a variety of languages is a part of this, as is
instruction in the theory underlying compilers.

-- 
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" ("I found it!") but rather "hmm....that's
funny..."  --   Isaac Asimov




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~1998-09-07  0:00 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-01  0:00 Expressive Case Statements (was: Software landmines) Brian Rogoff
  -- 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                                             ` Dr Richard A. O'Keefe
1998-09-02  0:00                                               ` Robert I. Eachus
1998-09-04  0:00                                                 ` Al Christians
1998-09-02  0:00                                               ` Matthew Heaney
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-02  0:00                                             ` Richard D Riehle
1998-09-02  0:00                                               ` Robert I. Eachus
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

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