From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 4 May 93 16:25:08 GMT From: wdl39!mab@ford-wdl1.arpa (Mark A Biggar) Subject: Re: Passing procedures as parameters to procedures. Message-ID: <1993May4.162508.13164@wdl.loral.com> List-Id: In article <1993May4.154040@di.epfl.ch> Magnus.Kempe@di.epfl.ch (Magnus Kempe) writes: >In article <1s5gae$kr4@huon.itd.adelaide.edu.au>, andrewd@winnie.cs.adelaide.e du.au (Andrew Dunstan,,2285592,) writes: >: As I pointed out in this group about a year ago, there are some things >: that you want to be able to do that you just can't with generics. If >: anybody can provide me with a good, clean, Ada equivalent of the >: following Pascal code, I'll send him/her (first winner only!) a good >: bottle of Australian red wine (damn this Beaujolais business!). >: [Pascal code omitted] >The solution is to make "D" visible. >package Wrap_AD is > procedure D; > generic > with procedure B; > procedure A_G; >end Wrap_AD; >package body Wrap_AD is > procedure D is begin null; end D; > procedure A_G is > begin > B; > end A_G; >end Wrap_AD; >generic > with procedure Y; >procedure X_G; >procedure X_G is >begin > Y; >end X_G; >procedure X is new X_G (Wrap_AD.D); >procedure A is new Wrap_AD.A_G (X); >... >A; >... >Two drawbacks: if D needs to access local variables of A_G, these >variables must be made global (but may be hidden in the body of >Wrap_A); the parameter B to A_G need not call D, but you may consider >it a "feature", a more powerful variant. I think there is a way in Ada9x generics to do this and still keep the nesting of d with out resorting to access to subprogram types. If b were to be defined as a generic subprogram inside a generic package, then by using the new genreic package formals you can instantate a with a generic version of b that can be instantiated inside the instantiation of a. -- Mark Biggar mab@wdl1.wdl.loral.com