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,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed.pionier.net.pl!news.nask.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: Wojtek Narczynski Newsgroups: comp.lang.ada Subject: Enumeration representation enhancement proposal Date: Thu, 14 Oct 2004 11:31:38 +0200 Organization: tp.internet - http://www.tpi.pl/ Message-ID: NNTP-Posting-Host: avn53.neoplus.adsl.tpnet.pl Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: nemesis.news.tpi.pl 1097746510 21651 83.27.47.53 (14 Oct 2004 09:35:10 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Thu, 14 Oct 2004 09:35:10 +0000 (UTC) User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Xref: g2news1.google.com comp.lang.ada:5193 Date: 2004-10-14T11:31:38+02:00 List-Id: Hello, Enumeration representation in their current form are not very useful, because there is no treatment of invalid values. That's why constants, and constant to enum mapping arrays are used so heavily in real interfacing code. Invalid external values are rather norm than exception, thus they deserve 'non-exceptional' treatment. The 'Valid attribute alleviates the problem, but it is not very convenient, for example won't work in case statements, it requires to have two different ways to log the value (valid and invalid). Maybe this could be improved in Ada 2005? For example: type Mix_Code is (Red, Green, Blue, Grey); -- Modest proposal for Mix_Code use (Red => 1, Green => 2, Blue => 3, Grey => others); This should be relatively straightforward to implement, and would cover most needs. However... -- Die-hard proposal for Mix_Code use (Red => 1 | 10, Green => 11 .. 20, Blue => 21 .. 30 | 40, Grey => others); An unambiguous mapping from the rep value to Ada enum would be required, not the other direction. Regards, Wojtek