home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / ada / 2366 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  1.6 KB

  1. Path: sparky!uunet!sequent!ogicse!uwm.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!think.com!linus!linus.mitre.org!mbunix.mitre.org!costello
  2. From: costello@mbunix.mitre.org (Costello)
  3. Newsgroups: comp.lang.ada
  4. Subject: Instantiating a Generic Pkg with a Variant Rcd
  5. Message-ID: <1992Aug14.174855.6049@linus.mitre.org>
  6. Date: 14 Aug 92 17:48:55 GMT
  7. Article-I.D.: linus.1992Aug14.174855.6049
  8. Sender: news@linus.mitre.org (News Service)
  9. Distribution: usa
  10. Organization: The MITRE Corp., Bedford, Ma.
  11. Lines: 37
  12. Nntp-Posting-Host: mbunix.mitre.org
  13.  
  14. Hi folks,
  15.    I have the following situation:
  16.  
  17. (1) I have a generic (list handling) package
  18. (2) I want to instantiate it with a variant record
  19.  
  20. eg. generic
  21.       type Element_Type is private;
  22.     Package Linked_List_Handler is
  23.     ...
  24.  
  25. I want to instantiate this with the type:
  26.    type Variant_Rcd (c : discr_type) is record
  27.    ...
  28.       case c is
  29.    ...
  30.       end case;
  31.    end  record;
  32.  
  33. When I compile this I get the error:
  34.  
  35. >>>>SEMANTIC : Constrained subtype required <3.6.1:6>
  36.  
  37. I'm afraid that the LRM pages weren't very helpful (to me anyway).
  38. Does this mean error that I cannot instantiate a generic pkg with
  39. a variant record?  Note: when I put a default value with the 
  40. discriminant in the variant record (i.e. c : discr_type := init_value)
  41. then it compiles fine, but from testing it appears that the
  42. generic pkg is working with the record that has c = init_value, and
  43. is not variable (i.e. not really variant).  Could someone please
  44. explain the finer points of generic pks with variant records?
  45.  
  46. Please mail responses directly to me at:
  47.   
  48.    costello@mitre.org
  49.  
  50. Thanks.  /Roger
  51.