comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Enumeration representation clause surprise.
Date: Wed, 11 Jun 2008 12:10:33 -0700 (PDT)
Date: 2008-06-11T12:10:33-07:00	[thread overview]
Message-ID: <4a84770f-e273-41ad-a8ef-f22a9896b544@i36g2000prf.googlegroups.com> (raw)
In-Reply-To: 871w346k4j.fsf@willow.rfc1149.net

On Jun 11, 8:56 am, Samuel Tardieu <s...@rfc1149.net> wrote:
> Adam> This seems odd to me.  Having GNAT select a biased component in
> Adam> Christoph's example makes some sense, since a compiler can choose any
> Adam> representation it likes.  But in Markus' case, he specifically asked
> Adam> for a certain representation for the enumeration types---should GNAT
> Adam> take it upon itself to change that, and display a warning that doesn't
> Adam> make it clear that it's disrespecting his request to have the
> Adam> enumeration represented a certain way?
> Adam>
> Adam> I dunno... maybe this would be acceptable to some, and apparently
> Adam> Markus thinks it's OK, but ... it's just not what I would expect ...
> Adam> I guess it's a subjective thing.
>
> I would prefer an error indeed,

Then there's no reason it couldn't generate one... implementations are
allowed to reject any representation clauses (including component
clauses) that they don't support, and there's nothing in the
Implementation Advice of 13.5.1 that would "require" (or advise) an
implementation to support this.  (In fact, there's nothing that would
"require" an implementation to implement biased values as in
Christopher's example.)


> but I can't seem to find a clause in
> chapter 13 which says that in records with representation clauses the
> representation given for objects when created independently the
> enumeration representation clause must be honored.

Technically, that may be correct, although technically it may be that
the RM doesn't require the specified representation to be honored for
*any* objects, stand-alone or component.  At least I couldn't find
anything specific, unless this is "generally implied" by the whole
chapter or by 13.1.  It may be that it's legal for an implementation
to accept an enumeration representation clause and then never apply
it.  But components are objects, and I don't see anything in 13.4 that
would apply unequally to component objects vis-a-vis stand-alone
objects.

Anyway, since it's clearly legal for an implementation to reject
Markus' code, I think it should.  Although it may be *possible* that
an implementation *could* find a way to obey the record rep clause by
using a different representation for the enumeration component (if
this is indeed legal), there's a 0% chance that any such usage would
be what the programmer intended, and a 100% chance that a usage like
this would indicate an error on the programmer's part.

                                   -- Adam



  reply	other threads:[~2008-06-11 19:10 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-11 11:38 Enumeration representation clause surprise Markus Schoepflin
2008-06-11 12:30 ` christoph.grein
2008-06-11 12:56   ` Markus Schoepflin
2008-06-11 13:08     ` christoph.grein
2008-06-11 13:28     ` Samuel Tardieu
2008-06-11 13:48       ` Markus Schoepflin
2008-06-11 13:56         ` Samuel Tardieu
2008-06-11 14:58       ` Adam Beneschan
2008-06-11 15:23         ` Markus Schoepflin
2008-06-12  2:37           ` Randy Brukardt
2008-06-12  2:37           ` Randy Brukardt
2008-06-11 15:56         ` Samuel Tardieu
2008-06-11 19:10           ` Adam Beneschan [this message]
2008-06-11 19:59             ` Niklas Holsti
2008-06-12  1:16               ` tmoran
2008-06-12  8:27                 ` christoph.grein
2008-06-12  8:45               ` Markus Schoepflin
2008-06-12 16:43                 ` Mike Silva
2008-06-12 18:41                   ` Markus Schöpflin
2008-06-12 20:10                     ` Mike Silva
2008-06-12 20:52                       ` Simon Wright
2008-06-12 23:36                         ` Mike Silva
2008-06-13  5:49                           ` Simon Wright
2008-06-13  7:21                       ` Keith Thompson
2008-06-13 13:31                         ` Mike Silva
2008-06-13 14:45                           ` Markus Schoepflin
2008-06-13 17:52                           ` Keith Thompson
2008-06-13  9:14                       ` Jean-Pierre Rosen
2008-06-12 19:05 ` richtmyer
2008-06-12 21:26   ` Samuel Tardieu
2008-06-12 22:42     ` Adam Beneschan
2008-06-13  7:11       ` Samuel Tardieu
2008-06-13  8:27       ` christoph.grein
2008-06-13 16:21         ` Adam Beneschan
2008-06-15 19:33           ` Robert A Duff
2008-06-16 14:50             ` Adam Beneschan
2008-06-16 19:18               ` Robert A Duff
2008-06-17  6:03               ` christoph.grein
2008-06-17  7:22                 ` christoph.grein
2008-06-13  8:24     ` Peter Hermann
2008-06-13 14:47       ` Samuel Tardieu
2008-06-14 11:48         ` John B. Matthews
replies disabled

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