home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!munnari.oz.au!manuel!csc.canberra.edu.au!jarrah!tp923021
- From: tp923021@jarrah.canberra.edu.au (Ben Elliston)
- Subject: Generics?
- Message-ID: <tp923021.715953043@jarrah>
- Sender: news@csc.canberra.edu.au
- Organization: Info Sci & Eng, University of Canberra, AUSTRALIA
- Date: 8 Sep 92 11:50:43 GMT
- Lines: 47
-
- 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;
-
- As it stands now, it seems that since the "pointer" variable (which
- indicates the current "highwater" mark of the array) is a natural, that
- Ada won't allow a natural to access an array indexed by some unknown
- (generic) type.
-
- For example, if the array was instantiated using a subtype of naturals
- (0 .. 100), allowing a natural to access elements of the array could
- lead to errors (of course, stack.data_store(103) would cause problems).
-
- Basically, I need to be able to "look at" any element in the array
- regardless of how large an array is defined in the given procedure using
- this package.
-
- I'm not too familiar with generics, and if someone could shed some light
- on this, I would really appreciate it.
-
- Many thanks.
-
- Cheers,
- %Ben%
- ------------------------------------------------------------------------------
- Ben Elliston | This message
- Bachelor of Engineering (Computer Engineering) | brought to you
- University of Canberra | by the machine
- Internet: tp923021@fir.canberra.edu.au | that goes
- FidoNet: 3:620/262 | 'ping'!
- -------------------------------------------------------+----------------------
- Some people make champagne out of water.
- ------------------------------------------------------------------------------
-
-