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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ce896fd16cf323ae X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!news2.telebyte.nl!news-fra1.dfn.de!newscore.univie.ac.at!newsmi-eu.news.garr.it!NewsITBone-GARR!newsserver.cilea.it!news.crs4.it!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Enumeration representation enhancement proposal Date: 20 Oct 2004 10:58:46 +0200 Organization: CRS4, Center for Adv. Studies, Research and Development in Sardinia Message-ID: References: <2t7sd8F1rsqh9U1@uni-berlin.de> NNTP-Posting-Host: jacob.crs4.it Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pietro.crs4.it 1098257751 17829 156.148.71.80 (20 Oct 2004 07:35:51 GMT) X-Complaints-To: news@nntpserver.crs4.it. NNTP-Posting-Date: 20 Oct 2004 07:35:51 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5502 Date: 2004-10-20T07:35:51+00:00 List-Id: Wojtek Narczynski wrote: > > for Colours use (Red => 1, Green => 2, Blue => 4, Muddy => others); > > > > if Muddy < Blue then > > -- Do we ever get here? Both 3 and 5 represents Muddy. The one > > -- is smaller than 4 (which represents Blue), the other one > > -- isn't. end if; > > end if; > > Clearly, representation has no impact on comparison. Wrong. > So we do not get there, granted that such is the order of > declaration in Ada. > > The above code is not harder to compile than: procedure Enumeration_Representation is type Colours is (Red, Green, Blue, Muddy); > for Colours use (Red => 1, Green => 3, Blue => 2, Muddy => 4); > > A, B : Colors; begin > if A < B then null; end if; end Enumeration_Representation; Is not correct Ada. The LRM clearly states (can't remember where, though) that the order of the representation should be the same as that of the original declaration of the enumeration. > Here the result is also rather unrelated to the underlying rep > values order. Except that your code isn't valid Ada. > Also, a simple "cannonicalization" {take the least possible 'others' > value to the register (not memory)} makes the case with 'others' > identical to current situation. But computationally slower. - Which I suspect is the whole reason for the order rule for enumeration representations. Jacob -- "[...] *transfer* a bit of salary from the person who writes a bug to the person that finds a bug..." -- Keith Ray