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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Problem with Position of the enumeration Type Date: Thu, 24 Jan 2019 01:20:16 +0200 Organization: Tidorum Ltd Message-ID: References: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net VnvY+o7p0rnVE5iVurOTEAwbCiXogtkwkPPgcReXwJHiQokMCT Cancel-Lock: sha1:yFgQESjFrqM10Zi6QRromDaAgq0= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:55349 Date: 2019-01-24T01:20:16+02:00 List-Id: On 19-01-24 00:35 , Simon Wright wrote: > Niklas Holsti writes: > >> Such rules also commonly say that such types should not be used as >> array index types, because of the possible introduction of gaps in the >> array representations. > > Not, it seems, with GNAT: [skip example] Nice to know. > I'd think any other behaviour would be unreasonable (though I can't see > any statement about it in the ARM). Avoiding gaps in such arrays means that GNAT is effectively using the position number as the (machine-level) index, which means that indexing with an arbitrary enumeration value (not a loop induction variable) requires the use of the 'Pos function, with its possible longish execution time for a gappy enumeration. So it's a space vs time trade-off, and GNAT chooses to reduce space at the cost of time. I too think that this is the choice less likely to surprise users. While enumeration representation clauses are a logical and sometimes useful feature, they are not very often the best design approach -- or not as often as one first thinks, when learning about them. I tend to use them only for outputs on the HW level, not so much for inputs (because of the need for validity checking that I commented on). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .