comp.lang.ada
 help / color / mirror / Atom feed
From: "Ken Garlington" <Ken.Garlington@computer.org>
Subject: Re: Representation clause for enumeratives
Date: Sun, 11 Feb 2001 01:09:25 GMT
Date: 2001-02-11T01:09:25+00:00	[thread overview]
Message-ID: <9Dlh6.4497$y03.296626@news.flash.net> (raw)
In-Reply-To: 963tos$atu$1@nnrp1.deja.com


"Robert Dewar" <dewar@gnat.com> wrote in message
news:963tos$atu$1@nnrp1.deja.com...
: In article <27eh6.3787$y03.254014@news.flash.net>,
:   "Ken Garlington" <Ken.Garlington@computer.org> 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/





  reply	other threads:[~2001-02-11  1:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-08  9:53 Representation clause for enumeratives Sandro Binetti
2001-02-08 10:12 ` Tarjei T. Jensen
     [not found]   ` <95u470$ho1$1@nnrp1.deja.com>
     [not found]     ` <95ua6q$mp4$1@nnrp1.deja.com>
2001-02-08 15:41       ` M. Kotiaho
2001-02-08 16:27         ` Steve O'Neill
2001-02-09  7:26           ` Sandro Binetti
2001-02-09  9:29           ` Martin Dowie
2001-02-08 15:55     ` Marin David Condic
2001-02-08 16:22 ` Rod Chapman
2001-02-10  6:34   ` Robert Dewar
2001-02-12 11:32     ` Rod Chapman
2001-02-08 18:52 ` Greg Bek
     [not found] ` <Ndyg6.1048$y03.96769@news.flash.net>
2001-02-09  5:02   ` Ken Garlington
2001-02-10  6:29     ` Robert Dewar
2001-02-10 16:37       ` Ken Garlington
2001-02-10 17:29         ` Robert Dewar
2001-02-11  1:09           ` Ken Garlington [this message]
2001-02-11  5:27             ` Robert Dewar
2001-02-11 12:53               ` Laurent Guerby
2001-02-12  0:24                 ` Robert Dewar
2001-02-12 20:10                   ` Laurent Guerby
2001-02-11 14:50               ` Ken Garlington
2001-02-10 17:31         ` Robert Dewar
2001-02-11  1:09           ` Ken Garlington
2001-02-11  5:28             ` Robert Dewar
2001-02-11 14:50               ` Ken Garlington
2001-02-12  0:30                 ` Robert Dewar
2001-02-12  2:34                   ` Ken Garlington
2001-02-10  6:19   ` Robert Dewar
2001-02-10 11:42     ` David C. Hoos, Sr.
2001-02-10 16:37     ` Ken Garlington
     [not found] ` <3A829EB8.A098925E@baesystems.com>
     [not found]   ` <95uae3$n5j$1@nnrp1.deja.com>
2001-02-12  9:12     ` Stuart Palin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox