home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / ada / 2552 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.0 KB  |  58 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!munnari.oz.au!manuel!csc.canberra.edu.au!jarrah!tp923021
  3. From: tp923021@jarrah.canberra.edu.au (Ben Elliston)
  4. Subject: Generics?
  5. Message-ID: <tp923021.715953043@jarrah>
  6. Sender: news@csc.canberra.edu.au
  7. Organization: Info Sci & Eng, University of Canberra, AUSTRALIA
  8. Date:  8 Sep 92 11:50:43 GMT
  9. Lines: 47
  10.  
  11. Thanks to those regarding my problem with the case statement .. all
  12. fixed now .. and much appreciated!
  13.  
  14. I've since moved onto making an array a generic type (such as this):
  15.  
  16. GENERIC
  17. Type Index IS (<>);
  18.  
  19. [..]
  20.  
  21. Type Stack_Array IS Array(Index) of Character;
  22.  
  23. Type Stack_Type IS RECORD
  24.   Data_Store: Stack_Array;
  25.   Pointer: Natural;
  26. END RECORD;
  27.  
  28. As it stands now, it seems that since the "pointer" variable (which
  29. indicates the current "highwater" mark of the array) is a natural, that
  30. Ada won't allow a natural to access an array indexed by some unknown
  31. (generic) type.
  32.  
  33. For example, if the array was instantiated using a subtype of naturals
  34. (0 .. 100), allowing a natural to access elements of the array could
  35. lead to errors (of course, stack.data_store(103) would cause problems).
  36.  
  37. Basically, I need to be able to "look at" any element in the array
  38. regardless of how large an array is defined in the given procedure using
  39. this package.
  40.  
  41. I'm not too familiar with generics, and if someone could shed some light
  42. on this, I would really appreciate it.
  43.  
  44. Many thanks.
  45.  
  46. Cheers,
  47. %Ben%
  48. ------------------------------------------------------------------------------
  49. Ben Elliston                                           | This message
  50. Bachelor of Engineering (Computer Engineering)         | brought to you
  51. University of Canberra                                 | by the machine
  52. Internet: tp923021@fir.canberra.edu.au                 | that goes
  53. FidoNet:  3:620/262                                    | 'ping'!
  54. -------------------------------------------------------+----------------------
  55. Some people make champagne out of water.
  56. ------------------------------------------------------------------------------
  57.  
  58.