comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: ObjectAda vs Gnat -- bugs
Date: 1997/05/16
Date: 1997-05-16T00:00:00+00:00	[thread overview]
Message-ID: <EAAIBG.A7s@world.std.com> (raw)
In-Reply-To: EA93C3.CF4@thomsoft.com


In article <EA93C3.CF4@thomsoft.com>, Keith Thompson <kst@sd.aonix.com> wrote:
>Actually, I believe ObjectAda is correct on this one -- but the reasons
>are rather obscure. ...
>...
>So, it is legal in Ada 95 (but illegal in Ada 83) to use an object
>renaming declaration to rename an enumeration literal.

Ah, at least *somebody* knows the right answer.  ;-)

It seems to me that when so many people get the *wrong* answer (see
below) ...

Various people wrote:

> Janus gives:
> *ERROR* Renamed object must be a variable or a constant (6.4.3) [RM
> 8.5.1(4)]
> 
> Enumeration literals like Gray0 are actually parameterless functions
> so what you need is: ...

> > If gnat is correct ( probably gnat!!!), 
> 
> Good guess! ...


> > Which of the compilers is correct ?
> 
> gnat; see below ...


> <<If gnat is correct ( probably gnat!!!), the internal package RGB_Value does
>  not have any influence, how can I have the enumeration values Gray* and
>  Grey* of the same type or subtype with the same internal value ?>>
> 
> Well I am not sure where you get the "probably gnat" from, but in this case
> it seems obvious that GNAT is right, unless I am missing something.  ...

When so many are wrong, including at least one compiler writer, it's
probably a problem with the language, not with all those people.  The
problem here, I think, is that enumeration literals are functions, in
Ada, which is completely weird, given that string_literals and
numeric_literals and null literals are just values.

Perhaps the reasoning was: (1) Language Design Principle: Subprograms,
and only subprograms, should be overloadable.  (2) We want enum lits to
be overloadable.  (3) Therefore, we have to pretend that enum lits are
functions.

Instead, it would be better to replace step (3) in the reasoning with
(3) Oops, I guess we were wrong about step (1); let's modify our
Principle.

I guess it's not quite *that* simple -- entries are also overloadable.
But entries really *are* like procedures in a lot of ways, so it's
natural to make the connection between subprograms and entries.  But
enum lits are not "naturally" anything at all like functions -- they're
more like constant objects.

Maybe I'm completely wrong about the chain of reasoning, since, I
believe, that in early versions of Ada, integer literals were overloaded
on all integer types.  Then named numbers and universal_integer were
invented, and the rules about literals were changed...

- Bob




  reply	other threads:[~1997-05-16  0:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-16  0:00 ObjectAda vs Gnat -- bugs Keith Thompson
1997-05-16  0:00 ` Robert A Duff [this message]
1997-05-16  0:00   ` Robert Dewar
1997-05-18  0:00     ` Nick Roberts
1997-05-19  0:00       ` Robert Dewar
1997-05-20  0:00         ` Nick Roberts
1997-05-21  0:00           ` Robert Dewar
1997-05-23  0:00   ` Stephen Leake
1997-05-24  0:00     ` Robert A Duff
1997-05-28  0:00       ` Stephen Leake
1997-05-30  0:00         ` Samuel Mize
1997-05-30  0:00         ` Robert A Duff
1997-05-30  0:00           ` Matthew Heaney
1997-05-31  0:00             ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1997-05-30  0:00 John Walker
1997-05-19  0:00 tmoran
1997-05-19  0:00 ` Jon S Anthony
1997-05-20  0:00   ` Nick Roberts
1997-05-25  0:00     ` Tom Moran
1997-05-20  0:00   ` Jeff Carter
1997-05-15  0:00 granger
1997-05-15  0:00 ` Samuel A. Mize
1997-05-15  0:00 ` Samuel A. Mize
1997-05-15  0:00 ` Robert Dewar
1997-05-16  0:00   ` David L Brown
1997-05-16  0:00     ` Robert Dewar
1997-05-17  0:00       ` Tom Moran
1997-05-18  0:00         ` Jon S Anthony
1997-05-19  0:00         ` Tucker Taft
1997-05-19  0:00       ` Tom Moran
1997-05-15  0:00 ` Stephen Leake
1997-05-16  0:00   ` Jon S Anthony
1997-05-16  0:00   ` Tucker Taft
1997-05-16  0:00     ` Jon S Anthony
1997-05-16  0:00       ` Tom Moran
1997-05-16  0:00       ` Robert Dewar
1997-05-17  0:00         ` Jon S Anthony
1997-05-16  0:00 ` Robert A Duff
1997-05-16  0:00   ` Robert Dewar
replies disabled

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