milne@ICSE.UCI.EDU (Alastair Milne) (06/22/86)
Using an enumeration-indexed case to choose the procedure to be called will work if all the procedures to be called are known and available at the time that case is compiled. It will therefore work if all the enumeration-passing calls are in the same program unit as the case, or if they are exported by a package which will permit only "procedures" known to it (its own, or others from packages used in the specification) to be passed in. It will not work in a library package exporting routines to be applied to routines from units not known to the package. Routines that come to mind immediately are in the field of numeric analysis: curve fitting, best fits, adaptive quadrature, etc. . In these cases what one needs is a routine which, given some routine x to produce original function values, calls that routine as it needs for input to its own algorithm. Such packages would be essential parts of libraries for numeric analysis. Their routines could be applied to any data-producing routine a user supplied, with algorithms 50 years old or produced yesterday. But in Ada, the old approach of simply passing that routine as another parameter is not available. A good point has already been made on this board that in using Ada, one can find that the way one used to do something is no longer available, only to discover that it can be done in new and superior, more secure ways. I hope that will turn out to be so of this case. Alastair Milne
rcd@nbires.UUCP (Dick Dunn) (07/03/86)
I think it's unfortunate that anyone ever suggested the idea of enumerating procedures which might be called and suppying an enumeration value instead of a procedural parameter. The question [I hope!] was never whether one could construct an Ada program which would have the same effect as a program in another language using procedural parameters...Turing equivalence is a nice tool but it's not the point. The fact that not all languages have procedural parameters gives some weight to the Ada position. The fact that C, Pascal, Modula, FORTRAN, Algol, and many other languages do have procedural parameters gives weight to the position that the lack of procedural parameters is a shortcoming of Ada. The argument that procedural parameters can be simulated is really irrelevant. The issues have to do with convenience and safety, not simple expressive power in a theoretical sense. (Most languages are equivalent in that theoretical sense.) Hence the discussion would be much more useful if it concentrated on Ada solutions which represent something like procedural parameters with a notation comparably concise and convenient. Adding an enumerated type, constructing the (unenforced!) correspondence between enumeration values and procedures, and replacing a single procedure invocation with a case statement over an enumeration value (assuming that the set of procedures of interest is actually a priori enumerable!) is not at all the same in any way of interest to a practicing programmer. A better answer is necessary here. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Simpler is better.