comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!net news.upenn.edu!uofs!guinness.cs.uofs.edu!beidler@ucbvax.Berkeley.EDU  (Jack Bei
Subject: Re: Generics?
Date: 14 Sep 92 15:00:11 GMT	[thread overview]
Message-ID: <11001@platypus.uofs.uofs.edu> (raw)

In article <tp923021.715953043@jarrah>, tp923021@jarrah.canberra.edu.au (Ben El
liston) writes:
|> Thanks to those regarding my problem with the case statement .. all
|> fixed now .. and much appreciated!
|> 
|> I've since moved onto making an array a generic type (such as this):
|> 
|> GENERIC
|> Type Index IS (<>);
|> 
|> [..]
|> 
|> Type Stack_Array IS Array(Index) of Character;
|> 
|> Type Stack_Type IS RECORD
|>   Data_Store: Stack_Array;
|>   Pointer: Natural;
|> END RECORD;
|> 

Something still  seems to be missing -- given the two other follow
ups to this article, I guess that I'm not the only one.  Let me add
my two cents.  My package spec. for this package is:

generic

   type Object_Type is private ; -- only one generic instantiation parm.

package Stack_Pt_Pt is

   Type Stack_Type (Max_Size : positive := 32) is private ;

     . . .
   -- Push, Pop, and other specs. here

private

   type Stack_Array_Type is array (positive range <>) of Object_Type ;

   type Stack_Type (Max_Size : positive := 32) is
      record
	 Top    : natural := 0 ;
	 Actual : Stack_Array_Type (1 .. Max_Size) ;
      end record ;

end Stack_Pt_Pt ;

By having Stack_Type declared with a discriminant, the client has
control over determining the max. size of each stack.

My convention for component package names is:

     Component_Xxx_Yyy

where "Component" is the component supportted by the package, 
"Xxx" is "Pt" or "Lpt" to indicate the type of instantiation 
parameter being supportted, and "Yyy" is either "Pt", "Lpt", 
or "En" to indicate the component visibility as either private,
limited private, or totally encapsulated (One copy) by the package.
-- 
+------------------------------------------------------------------+
|  John (Jack) Beidler				                   |
|  Prof. of Computer Science Internet: BEIDLER@JAGUAR.UOFS.ED      |
|  University of Scranton              beidler@guinness.cs.uofs.edu|
|  Scranton, PA 18510	      Bitnet : BEIDLER@SCRANTON            |
|                                                                  |
|          Phone: (717) 941-7446	 FAX:   (717) 941-4250     |
+------------------------------------------------------------------+

             reply	other threads:[~1992-09-14 15:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-09-14 15:00 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!net [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-02 22:33 Generics??? Michael Andersson
2001-07-02 17:48 ` Generics??? James Rogers
2001-07-02 18:54   ` Generics??? Ehud Lamm
2001-07-02 18:42 Generics??? Beard, Frank
2001-07-03 10:32 ` Generics??? Anders Wirzenius
2001-07-03 17:31   ` Generics??? Stephen Leake
2001-07-03 19:09   ` Generics??? tmoran
2001-07-04  5:30     ` Generics??? Anders Wirzenius
1992-09-09  5:26 Generics? Andrew Dunstan
1992-09-09  1:34 Generics?  Rob Allen
replies disabled

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