home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3724 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.7 KB  |  73 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!The-Star.honeywell.com!saifr00.cfsat.honeywell.com!lam
  3. From: lam@saifr00.cfsat.honeywell.com (Josh Lam)
  4. Subject: Novice Question on Record Representation
  5. Message-ID: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com>
  6. Organization: Honeywell Air Transport Systems Division
  7. Date: Wed, 16 Dec 92 22:57:12 GMT
  8. Lines: 63
  9.  
  10. There is a type in another package I need to use in a record in my package.
  11. Unfortunately, that type is private and I need to use record representation
  12. for my record.
  13.  
  14. package Some_Package is
  15.  
  16.  type Some_Int is new integer;
  17.  for Some_Int'size use 16;
  18.  
  19.  type Some_Type is private
  20.  
  21.  -- etc etc
  22.  
  23.  private
  24.  
  25.   type Some_Type is new integer;
  26.   for Some_Type'size use 32;
  27.  
  28. end Some_Package;
  29.  
  30.  
  31. with Some_Package;
  32. package My_Package is
  33.  
  34.  type My_Rec (Choice: Boolean := True) is record
  35.    case Choice is
  36.      when True =>
  37.        A : Some_Package.Some_Int;
  38.        B : Some_Package.Some_Int;
  39.        C : Some_Package.Some_Type;
  40.      when False =>
  41.        D : Some_Package.Some_Int;
  42.    end case;
  43.  end record;
  44.    
  45.  for My_Rec use record
  46.     A      at 0 range 0..15;
  47.     B      at 0 range 16..31;
  48.     C      at 1 range 0..31;     -- of course there is an error here!
  49.     Choice at 2 range 0..31;
  50.     D      at 0 range 0..15;
  51.  end record;
  52.  
  53. -- etc etc
  54.  
  55. end My_Package;
  56.  
  57.  
  58. I know that I cannot do the above cos C is of Some_Package.Some_Type which
  59. is a private type.
  60.  
  61. So, other than yelling at the person and getting him to change his type
  62. to public, what are my alternatives given that I need to use record
  63. representation. Please also let me know some pros and cons (if any) to any
  64. alternative.
  65.  
  66. Thanks in advance!
  67.  
  68. -- 
  69. Josh Lam
  70. Honeywell Inc
  71. lam@saifr00.cfsat.honeywell.com
  72.  
  73.