comp.lang.ada
 help / color / mirror / Atom feed
From: mcsun!hp4nl!gufalet.let.rug.nl!rug4!laverman@uunet.uu.net  (Bert Laverman
Subject: Re: Hopefully simple question regarding generics
Date: 23 Oct 91 08:39:41 GMT	[thread overview]
Message-ID: <1991Oct23.083941.9755@cs.rug.nl> (raw)

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 <std/disclaimer>

  Bert Laverman,  Dept. of Computing Science, Groningen University
  laverman@cs.rug.nl			bert@arrakis.nl.mugnet.org

             reply	other threads:[~1991-10-23  8:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-10-23  8:39 mcsun!hp4nl!gufalet.let.rug.nl!rug4!laverman [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-10-21 18:36 Hopefully simple question regarding generics netnews.upenn.edu!uofs!guinness.cs.uofs.edu!beidler
1991-10-17  8:59 Stephen J Bevan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox