home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!agate!linus!linus.mitre.org!linus!mbunix!eachus
- From: eachus@Dr_No.mitre.org (Robert I. Eachus)
- Subject: Re: Variant Record Defaults
- In-Reply-To: BERRYMAN@orca.drep.dnd.ca's message of Wed, 2 Sep 1992 22:38:07 GMT
- Message-ID: <EACHUS.92Sep8114340@Dr_No.mitre.org>
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: dr_no.mitre.org
- Organization: The Mitre Corp., Bedford, MA.
- References: <1992Sep2.223807.9217@netfs.dnd.ca>
- Date: Tue, 8 Sep 1992 16:43:40 GMT
- Lines: 44
-
-
- In article <1992Sep2.223807.9217@netfs.dnd.ca> BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
-
- Please concider the following code fragment:
-
- package dstring is
- type text (maxlen: positive := 64) is private;
- ...
- end dstring;
-
- procedure useit is
- type buffer is record
- data: dstring.text;
- end record;
- aaa: buffer;
- bbb: dstring.text;
- begin
- null;
- end useit;
- ...
-
- I'm sure the reason is given in an obscure section of the LRM...
-
- No, it's an implementation issue. (Hint: What is the maximum size
- of an object of type buffer...) Most compilers today can deal with
- huge varying size obects which depend on a discriminant of the type,
- but not which depend on buried discriminants. In any case the
- solution is simple. Choose a "reasonable" maximum size for the
- discriminant and declare a subtype with that limit:
-
- subtype my_positive is range 1..40000;
-
- type text (maxlen: my_positive := 64) is private;
-
- If you really need huge strings, you're going to have to use
- explict pointers and manage the memory yourself.
-
- --
-
- Robert I. Eachus
-
- with STANDARD_DISCLAIMER;
- use STANDARD_DISCLAIMER;
- function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...
-