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 autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site ada-uts Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ima!inmet!ada-uts!richw From: richw@ada-uts Newsgroups: net.lang.ada Subject: Re: ForTran-Ada + flamette + question Message-ID: <4700034@ada-uts> Date: Wed, 28-May-86 11:54:00 EDT Article-I.D.: ada-uts.4700034 Posted: Wed May 28 11:54:00 1986 Date-Received: Fri, 30-May-86 08:34:59 EDT Nf-ID: #R:<8605210805.AA20308@ucbvax.Berke:-40:ada-uts:4700034:200:2811 Nf-From: ada-uts!richw May 28 11:54:00 1986 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. Abstractly, this new function is similar to "eval" in Lisp. Now, instead of binding characters sequences to function-pointers (as in C), just bind the character sequences to enumerals. Other comments about why I think the ability to pass procedures around was omitted from Ada: (note that these are just opinions -- I'm not quoting one of the design documents for Ada or anything like that) In a language like Lisp, you can actually create procedures AT RUN-TIME since they're just lists (i.e. data). However, in C and Ada this isn't true. In C, all procedures that you can point to at run-time are defined at compile time. I think this last fact is an important one to consider; the above method of mapping enumerals to subprogram calls works for Ada. It wouldn't work in Lisp because you can't list all of the subprograms that will exist when you run the program BEFORE you run it (because you can build Lisp procedures "on the fly"); thus, you can't define an enumeration type since that type has a finite number of compile-time enumerals. 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). If so, then omitting the ability to pass procedures around in Ada saved the language designers from adding more syntactic and semantic and run-time constructs to the language to support this. Considering the fact that Ada is already big, I think this was a wise decision -- especially since, with a minimal amount of work, you CAN do what you want (using the enumeral-to-subprogram method). Think about it -- strict type-checking becomes much more messy... It is possible to add this to your language (e.g. CLU), but I personally don't think it's worth complicating your language. Even though C lets you do it, C BY NO MEANS does type-checking of calls to procedures which were passed in as arguments (it doesn't even check that the number of arguments is correct). Yes, C is an "unsafe" language... Comments? Remember, these are casual remarks and opinions -- please think before you flame :-) Rich