home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / ada / 2604 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.6 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!uofs!guinness.cs.uofs.edu!beidler
  2. From: beidler@guinness.cs.uofs.edu (Jack Beidler)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Generics?
  5. Message-ID: <11001@platypus.uofs.uofs.edu>
  6. Date: 14 Sep 92 15:00:11 GMT
  7. References: <tp923021.715953043@jarrah>
  8. Sender: news@uofs.uofs.edu
  9. Organization: Department of Computing Sciences
  10. Lines: 67
  11. Nntp-Posting-Host: guinness.cs.uofs.edu
  12.  
  13. In article <tp923021.715953043@jarrah>, tp923021@jarrah.canberra.edu.au (Ben Elliston) writes:
  14. |> Thanks to those regarding my problem with the case statement .. all
  15. |> fixed now .. and much appreciated!
  16. |> 
  17. |> I've since moved onto making an array a generic type (such as this):
  18. |> 
  19. |> GENERIC
  20. |> Type Index IS (<>);
  21. |> 
  22. |> [..]
  23. |> 
  24. |> Type Stack_Array IS Array(Index) of Character;
  25. |> 
  26. |> Type Stack_Type IS RECORD
  27. |>   Data_Store: Stack_Array;
  28. |>   Pointer: Natural;
  29. |> END RECORD;
  30. |> 
  31.  
  32. Something still  seems to be missing -- given the two other follow
  33. ups to this article, I guess that I'm not the only one.  Let me add
  34. my two cents.  My package spec. for this package is:
  35.  
  36. generic
  37.  
  38.    type Object_Type is private ; -- only one generic instantiation parm.
  39.  
  40. package Stack_Pt_Pt is
  41.  
  42.    Type Stack_Type (Max_Size : positive := 32) is private ;
  43.  
  44.      . . .
  45.    -- Push, Pop, and other specs. here
  46.  
  47. private
  48.  
  49.    type Stack_Array_Type is array (positive range <>) of Object_Type ;
  50.  
  51.    type Stack_Type (Max_Size : positive := 32) is
  52.       record
  53.      Top    : natural := 0 ;
  54.      Actual : Stack_Array_Type (1 .. Max_Size) ;
  55.       end record ;
  56.  
  57. end Stack_Pt_Pt ;
  58.  
  59. By having Stack_Type declared with a discriminant, the client has
  60. control over determining the max. size of each stack.
  61.  
  62. My convention for component package names is:
  63.  
  64.      Component_Xxx_Yyy
  65.  
  66. where "Component" is the component supportted by the package, 
  67. "Xxx" is "Pt" or "Lpt" to indicate the type of instantiation 
  68. parameter being supportted, and "Yyy" is either "Pt", "Lpt", 
  69. or "En" to indicate the component visibility as either private,
  70. limited private, or totally encapsulated (One copy) by the package.
  71. -- 
  72. +------------------------------------------------------------------+
  73. |  John (Jack) Beidler                                   |
  74. |  Prof. of Computer Science Internet: BEIDLER@JAGUAR.UOFS.ED      |
  75. |  University of Scranton              beidler@guinness.cs.uofs.edu|
  76. |  Scranton, PA 18510          Bitnet : BEIDLER@SCRANTON            |
  77. |                                                                  |
  78. |          Phone: (717) 941-7446     FAX:   (717) 941-4250     |
  79. +------------------------------------------------------------------+
  80.