From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 29 Jun 93 17:44:57 GMT From: scf16!bashford@ford-wdl1.arpa (Dave Bashford) Subject: Re: Retrieving Rep Spec'ed Enumeration Values Message-ID: <1993Jun29.174457.21582@scf.loral.com> List-Id: In article ... wise@cs.umass.edu writes: >In article ... mab@dst17.wdl.loral.com (Mark A Biggar) writes: > In article I write: > >Suppose you had a type like so: > > type Color is ( Red, Green, Blue ); > > for Color use ( Red => 4, Green => 8, Blue => 16 ); > >I cannot seem to find a portable way to retrieve the values assigned > >in the rep-spec. Color'Pos is explicitly defined to be unaffected by > >the rep spec (LRM 13.3 paragraph 6). > > [suggestion for using unchecked_conversion, ...] > >I need to be able to communicate enumeration types over a network >link. Transmitting them a string rep ('image) is expensive at both >ends of the link -- so the rational thing to do seemed to be set the >numeric representation (they are called ENUMERATION types, you know >:-) and send that! > > But, if you really really need it just declare an anonymous array to be > used for conversions: > > internal_colors: array (Color) of integer := (4,8,16); > Am I missing something here ? Given the following procedures and the above declarations, and ignoring the storage size problem, both procedure calls will send exactly the same thing (4), won't they ? procedure Send( Value: in Color ); procedure Send( Value: in integer ); ... Send(Red); Send(internal_colors(Red)); The reason that there isn't an explicit attribute for retrieving the value of an enumeration-type object is the same reason that there isn't one for retrieving the value of an integer-type object - it isn't necessary. -- db bashford@srs.loral.com (Dave Bashford, Sunnyvale, CA)