From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,FROM_WORDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e6cdf6ff50e684 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-10 17:09:27 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!europa.netcrusader.net!205.252.116.205!howland.erols.net!nntp.flash.net!news.flash.net!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: <95tqbh$ag7$1@nnrp1.deja.com> <962n4v$fmg$1@nnrp1.deja.com> <27eh6.3787$y03.254014@news.flash.net> <963tos$atu$1@nnrp1.deja.com> Subject: Re: Representation clause for enumeratives X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <9Dlh6.4497$y03.296626@news.flash.net> Date: Sun, 11 Feb 2001 01:09:25 GMT NNTP-Posting-Host: 65.67.100.167 X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 981853765 65.67.100.167 (Sat, 10 Feb 2001 19:09:25 CST) NNTP-Posting-Date: Sat, 10 Feb 2001 19:09:25 CST Organization: FlashNet Communications, http://www.flash.net Xref: supernews.google.com comp.lang.ada:5105 Date: 2001-02-11T01:09:25+00:00 List-Id: "Robert Dewar" wrote in message news:963tos$atu$1@nnrp1.deja.com... : In article <27eh6.3787$y03.254014@news.flash.net>, : "Ken Garlington" wrote: : > By the way, this description : > of the shifting of the allowable range (selecting different : > unbiased representations) would be very useful in the GNAT : > user guide. I couldn't find it. : : Information on representation matters is really part of the : language, and in particular is required to be documented by : RM M(43). All such information is in the GNAT reference manual, : not in the users guide (which is about how to use the compiler, : rather than how to write programs). The divisision is not : always perfectly clear, but in this case, there is a chapter : called "Representation Clauses and Pragmas", which a section : called "Enumeration Clauses", that contains this information : as well as other important information. Perhaps this is in the 3.13p version of the reference manual? My version 3.12p dated 6 September 1999 does not have the specific information I suggested. I searched for the word "representation", and found the following with at least minimal bearing on the subject: [Under "Implementation Defined Pragmas"] No_Enumeration_Maps - similar to Discard_Names in C.5, but this is a restriction instead. For enumeration types with representation clauses the following attributes are not allowed.... [Under "Implementation Defined Attributes"] Enum_Rep - for every enumeration subtype S, S'Enum_Rep denotes a function.... [Under "Implementation Advice"] 3.5.5(8): Enumeration Values - For the evaluation of a call on S'Pos for an enumeration subtype, if the value of the operand does not correspond.... Followed. 13.4(9-10): Enumeration Representation Clauses - The recommended level of support for enumeration representation clauses is: An implementation need not support enumeration representation clauses for boolean types, but should at minimum support the internal codes in the range System.Min_Int.System.Max_Int [sic]. Followed. [Under "Interfacing to Other Languages" -> "Interfacing to C"] Ada enumeration types map to C enumeration types directly if pragma Convention C is specified, which causes them to have int length. Without pragma Convention C, Ada enumeration types map to 8, 16, or 32 bits (i.e. C types signed char, short, int respectively) depending on the number of values passed. This is the only case in which pragma Convention C affects the representation of an Ada type. [Under "Compatibility Guide" -> "Representation Clauses"] There is no mention of enumeration representation clauses in this section. : In particular, one very important item which is (very : unfortunately) left implementation defined is what happens : if you have an array whose index type is an enumeration type : with holes. There are two implementations: : : 1. Use the representation to index, fast, but can waste space : (a lot of space if you have a rep clause like the one that : started this thread). : : 2. Use the pos value to index, slow, but compact : : GNAT chooses the second, mostly because Verdix chose the : second, and we generally choose to be Verdix Ada 83 compatible : in such matters (in this case, this is also the choice made by : DEC Ada 83 and other Ada 83 compilers). This must also have been introduced after the 3.12p version... : Sent via Deja.com : http://www.deja.com/