home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc
- From: dlc@ddsdx2.jhuapl.edu (Dave Collard x7468)
- Subject: Re: Novice Question on Record Representation
- Message-ID: <1992Dec17.132850.2305@aplcen.apl.jhu.edu>
- Sender: news@aplcen.apl.jhu.edu (USENET News System)
- Organization: Johns Hopkins University
- References: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com>
- Distribution: usa
- Date: Thu, 17 Dec 92 13:28:50 GMT
- Lines: 80
-
- >Josh Lam
- >Honeywell Inc
- >lam@saifr00.cfsat.honeywell.com
-
- -- OOH, OOH, OOH!!! Something technical on comp.lang.ada! Wow!
- -- Today should become a federal holiday! :-)
-
- package Some_Package is
-
- type Some_Int is new short_integer;
- for Some_Int'size use 16;
-
- type Some_Type is private;
-
- private
-
- type Some_Type is new integer;
- for Some_Type'size use 32;
-
- end Some_Package;
-
-
- with Some_Package;
- package My_Package is
-
- XX : constant Integer := Integer(Some_Package.Some_Type'Size);
-
- type My_Rec (Choice: Boolean := True) is record
- case Choice is
- when True =>
- A : Some_Package.Some_Int;
- B : Some_Package.Some_Int;
- C : Some_Package.Some_Type;
- when False =>
- D : Some_Package.Some_Int;
- end case;
- end record;
-
- -- for My_Rec use record
- -- A at 0 range 0..15;
- -- B at 0 range 16..31;
- -- C at 1 range 0..31; -- of course there is an error here!
- -- Choice at 2 range 0..31;
- -- D at 0 range 0..15;
- -- end record;
-
- -- Is the storage unit on your machine really 32 bits? the '0' in "A at 0"
- -- refers to which storage unit to start the component at. But the answer
- -- to your question is that you CAN use rep specs with private types. The
- -- attributes of private types are also available (such as 'SIZE). The
- -- problem in your example is overlapping components of your record. Try:
-
- for My_Rec use record
- A at 0 range 0..15;
- B at 2 range 0..15;
- C at 4 range 0..31; -- of course there is an error here! NOT!
- Choice at 8 range 0..31;
- D at 0 range 0..15;
- end record;
-
- -- This works for me. Yes I actually compiled it.
-
- -- etc etc
-
- end My_Package;
-
- --I know that I cannot do the above cos C is of Some_Package.Some_Type which
- --is a private type.
- --
- --So, other than yelling at the person and getting him to change his type
- --to public, what are my alternatives given that I need to use record
- --representation. Please also let me know some pros and cons (if any) to any
- --alternative.
- --
- --Thanks in advance!
- --
-
- --Thor
- --dlc@ddsdx2.jhuapl.edu
- --collard@capsrv.jhuapl.edu
-