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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d0452dbe16ac0df4 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: ObjectAda vs Gnat -- bugs Date: 1997/05/16 Message-ID: #1/1 X-Deja-AN: 241977972 References: Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-05-16T00:00:00+00:00 List-Id: In article , Keith Thompson 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 ... > < 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