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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!husc6!panda!genrad!decvax!cca!holden From: holden@cca.UUCP (Russ Holden) Newsgroups: net.lang.ada Subject: Re: ForTran-Ada + flamette + question Message-ID: <8129@cca.UUCP> Date: Fri, 30-May-86 08:46:42 EDT Article-I.D.: cca.8129 Posted: Fri May 30 08:46:42 1986 Date-Received: Wed, 4-Jun-86 00:06:25 EDT References: <4700034@ada-uts> Organization: Computer Corp. of America, Cambridge List-Id: > > The following includes a suggestion for solving your problem, along > with my own defense of the decision to omit procedure-pointers from Ada: > > The first solution I can think of (and, I guess, the simplest?) would > be to define an enumeration type, where each enumeral (is that a > word?) corresponds to one of the functions you'd like to bind to a > key-sequence. Then just write a procedure that takes such an enumeral > as an "in" parameter and then "case"s on that parameter to the > appropriate call. > > Anyway, my point is that I think that one can do all that you can do in > C in Ada by using the above enumerals-to-subprogram mapping method; I'd > be interested if people can provide counter-examples (I realize that > you'd have to do more if the procedures you call take different numbers > of arguments, but then again, you'd have to be more fancy in C, too). Rich, you are missing out on the beauty of procedure passing. Simply put it gives you the ability to dynamically bind actions without the invoker of the procedure having to know about the procedure being called. A couple of examples are: 1) Table-driven code - Using C all you have to do is add a procedure to a table. Using the ADA enumerated-to-procedure mapping code modifications are involved (see below). 2) It provides the ability for higher levels of software to abstract procedures from lower levels such that lower levels call but do not "use" these procedures (in Parnas terminology). For example, (and this is not hypothetical) is a DBMS which wants to perform qualification of records against user-specified predicates before retreiving them (copying them off their page essentially). Since the code performing page level manipulations is generally at a much lower level in processing than the code which understands about the values in records a procedure made available to the page level is an appropriate mechanism. The use of enumerated types does no good and there are no real good solutions that I know of in ADA (if anyone has any please send me mail). I have used procedure pointers in lots of other situations where a high-level wants or needs to provide a service to a lower level. The only requirement is that a "standard" invokation mechanism be defined. -- Russell Holden Computer Corporation of America Four Cambridge Center Cambridge, MA 02142