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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,227757d168eaa8a5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: A question re meaning/use of the "for ... use ..." Date: 05 Dec 2004 10:59:03 -0500 Organization: Cuivre, Argent, Or Message-ID: References: <41b3291e$0$44072$5fc3050@dreader2.news.tiscali.nl> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1102262931 31002 212.85.156.195 (5 Dec 2004 16:08:51 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Sun, 5 Dec 2004 16:08:51 +0000 (UTC) Cc: David Botton To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: <41b3291e$0$44072$5fc3050@dreader2.news.tiscali.nl> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:6777 Date: 2004-12-05T10:59:03-05:00 Erik J Pessers writes: > Hi, > > A question re meaning/use of the "for ... use ..." construct. > > Given the code snippet at the bottom of this mail, I was sort of > expecting to see an output reading like: > > Pos for AA : 0 > Pos for BB : 2 > Pos for CC : 3 > > > > Instead (when compiling with bot Gnat3.15p and Gnat-3.4.2-2), > the actual code output reads: > > Pos for AA : 0 > Pos for BB : 1 > Pos for CC : 2 This is definitely a FAQ, but I don't see it at AdaPower. David; the Ada FAQ says it is maintained by the users, but I don't see any way to submit new FAQs. Please consider this a submission. The enumeration representation clause (see ARM 13.4) specifies the internal representation of an enumeral. The 'Pos attribute (see ARM Annex K) returns the position number of an enumeral. Position numbers start at 0 and increment by one for each enumeral. There is no standard attribute that returns the internal representation specified by the enumeration representation clause. However, GNAT provides the non-standard 'Enum_Rep for this purpose. > Anybody who can shed some light, and explain what will be going on > behind the curtains? Typical reasons for specifying an enum rep clause are for interfacing to another language, or for interfacing to hardware. In both cases, the value to be passed is specified by the external object, and the Ada code must match it. So for your type: > type enm is (aa, bb, cc) ; > for enm use > (aa => 0, > bb => 2, > cc => 3); if you pass "bb" to a C program, it will get the value 2. -- -- Stephe