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

  1. Newsgroups: comp.lang.ada
  2. 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
  3. From: eachus@Dr_No.mitre.org (Robert I. Eachus)
  4. Subject: Re: Variant Record Defaults
  5. In-Reply-To: BERRYMAN@orca.drep.dnd.ca's message of Wed, 2 Sep 1992 22:38:07 GMT
  6. Message-ID: <EACHUS.92Sep8114340@Dr_No.mitre.org>
  7. Sender: news@linus.mitre.org (News Service)
  8. Nntp-Posting-Host: dr_no.mitre.org
  9. Organization: The Mitre Corp., Bedford, MA.
  10. References: <1992Sep2.223807.9217@netfs.dnd.ca>
  11. Date: Tue, 8 Sep 1992 16:43:40 GMT
  12. Lines: 44
  13.  
  14.  
  15. In article <1992Sep2.223807.9217@netfs.dnd.ca> BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
  16.  
  17.    Please concider the following code fragment:
  18.  
  19.     package dstring is
  20.         type text (maxlen: positive := 64) is private;
  21.              ...
  22.         end dstring;
  23.  
  24.     procedure useit is
  25.        type buffer is record
  26.         data: dstring.text;
  27.        end record;
  28.        aaa: buffer;
  29.        bbb: dstring.text;
  30.     begin
  31.        null;
  32.     end useit;
  33.         ...
  34.  
  35.    I'm sure the reason is given in an obscure section of the LRM...
  36.  
  37.    No, it's an implementation issue.  (Hint: What is the maximum size
  38. of an object of type buffer...)  Most compilers today can deal with
  39. huge varying size obects which depend on a discriminant of the type,
  40. but not which depend on buried discriminants.  In any case the
  41. solution is simple.  Choose a "reasonable" maximum size for the
  42. discriminant and declare a subtype with that limit:
  43.  
  44.         subtype my_positive is range 1..40000;
  45.  
  46.     type text (maxlen: my_positive := 64) is private;
  47.  
  48.     If you really need huge strings, you're going to have to use
  49. explict pointers and manage the memory yourself.
  50.  
  51. --
  52.  
  53.                     Robert I. Eachus
  54.  
  55. with STANDARD_DISCLAIMER;
  56. use  STANDARD_DISCLAIMER;
  57. function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...
  58.