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=0.5 required=3.0 tests=BAYES_05,FROM_ADDR_WS autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 23 Oct 91 08:39:41 GMT From: mcsun!hp4nl!gufalet.let.rug.nl!rug4!laverman@uunet.uu.net (Bert Laverman ) Subject: Re: Hopefully simple question regarding generics Message-ID: <1991Oct23.083941.9755@cs.rug.nl> List-Id: Jack Beidler writes: > ... >he is using private types. It might be wise to create a "limited private" ver sion of this >Sort, > >generic > type Object_Type is limited private > type Array_range is (<>) ; > type array_type is array (Array_range) of Object_Type ; > with function "<" (left, right: Object_Type return boolean ; > with procedure SWAP (left, right : in out OBJECT_TYPE) ; >procedure Sort (An_Array : in out AArray_Type) ; > >which would need a procedure, like SWAP, to flip the object references around. Actually, the Modular Pascal standard library shows that even this interface ca n be cut down: PROCEDURE sort(lo, hi: integer; FUNCTION before(i, j: integer): boolean; PROCEDURE swap(i, j: integer)); If you've already taken the test and the swapping out of the sorter, why keep t he array? This way the sorter is at the minimal need-to-know situation. This form of prog ramming generics has more the aspect of frame-work reuse, than routine-reuse. Okay, okay. So maybe an Ada compiler will want to expand those generic paramete rs inline. Still, I think this is an excellent example of use of procedural parame ters, and in most cases the loss caused by the procedure calls will be minimal. Greetings, Bert -- #include Bert Laverman, Dept. of Computing Science, Groningen University laverman@cs.rug.nl bert@arrakis.nl.mugnet.org