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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Problem with Position of the enumeration Type Date: Sat, 26 Jan 2019 10:44:26 +0100 Organization: A noiseless patient Spider Message-ID: References: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 26 Jan 2019 09:44:27 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="d833269b972f19620c14587b50f51e12"; logging-data="30939"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CpNc+dFHZxnyhO+BNAtlP9SCiu7azt/c=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 Cancel-Lock: sha1:3wQhbGvSN2FdAPf3z/DJ4c157PM= In-Reply-To: Content-Language: de-DE Xref: reader01.eternal-september.org comp.lang.ada:55377 Date: 2019-01-26T10:44:26+01:00 List-Id: On 23.01.19 22:42, Niklas Holsti wrote: > > As others have also noted, enumeration representation clauses are used mostly when the enumeration value is an input (say, from some memory-mapped control register, or from a binary input file) or an output. Communication protocols and HW interfaces often define fields that encode some finite set of possible logical values/meanings, but where the encoding has gaps. > > A final note: if you use an enumerated type for an input value, it is wise to check if the input is valid before using it. Use the 'Valid attribute for this. However, this attribute can also have a non-trivial cost. For example, the compiler may implement the function call E_Test'Valid(E) by code that compares the (representation of) E against each of the valid values 10, 21, 34, 100, 255 in turn (although a better compiler would use a binary search). Has it been pointed out that one can use two enum types together, one for I/O and the other for internal purposes and then simply convert? type E_Test is (A, B, C); type E_for_IO is new E_Test; for E_for_IO use (A => 2#0000_1010# B => 2#0001_0101# C => 2#0010_0010#); ... some_E_Test := E_Test (some_E_for_IO); -- "HOTDOGS ARE NOT BOOKMARKS" Springfield Elementary teaching staff