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 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!cernvax!chx400!chx400!sicsun!disuns2!elcgl.epfl.ch!madmats From: madmats@elcgl.epfl.ch Newsgroups: comp.lang.ada Subject: Re: procedural variables Message-ID: <1991Feb16.141232.1@elcgl.epfl.ch> Date: 16 Feb 91 13:12:32 GMT References: <9102110959.aa23851@PARIS.ICS.UCI.EDU> <662@esosun.UUCP> <24590@neptune.inf.ethz.ch> <2834@cod.NOSC.MIL> Sender: news@disuns2.epfl.ch Organization: Ecole Polytechnique Federale de Lausanne List-Id: In my opinion, procedure variables were not included in Ada because of the restrictions that must be placed upon them, making the feature non-ortho- gonal. Most languages that have procedure variables allow only top-level (i.e. declared as library units or immediately within library packages) procedures as their values. This is the case of Modula-2 for instance. The reason for this restriction is obvious: otherwiswe, a local procedure might be called in a situation where its context is not present, as in the following example written in PV-Ada (Ada with proc. variables): ... type Proc is procedure; -- parameterless X : Proc; procedure P is A : Integer; procedure Q is begin A := A + 1; end; begin X := Q; end P; ... P; X; -- this should be a call to P.Q, which makes no sense. Now one might argue that it is easy to check (at runtime) if X's context is present at the moment X is called, but this is not so true because a simple check that P is currently being called is not sufficient as different invocations of P may create different contexts for Q, for instance by declaring subtypes with non-static bounds. This issue of 'dangling subprograms' is treated in more detail in the context of an object-oriented extension to Ada in Norman Cohen's report "Ada subtypes as subclasses", which I recommend. For Ada-9X, I would much prefer an object-oriented extension than support for procedure variables, because this would greatly extend the expressive power of the language and would simultaneoulsy provide support for procedure variables for those who really want them: a procedure value would be an object with no data and only one method. To me, a procedure value not tied to an object does not make much sense. After all, the 'need' for procedure variables has only become serious since people have been trying to interface x-toolkits with Ada (callbacks), but does that mean that callbacks are the right way of doing it ? Mats Weber