comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: ObjectAda vs Gnat -- bugs
Date: 1997/05/16
Date: 1997-05-16T00:00:00+00:00	[thread overview]
Message-ID: <dewar.863824104@merv> (raw)
In-Reply-To: EAAIBG.A7s@world.std.com


<<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.
>>

I agree with Bob here. The trouble is that although it makes moderately
consistent semantic sense to declare that enumeration literals are
functions, it does not make much sense from a programmer's point of view,
and it does not make much sense from an implementation point of view.
In GNAT, we find that we need special handling for enumeration literals
all over the place as a result of this rule. For example, look at the
code for handling object renamings:

      elsif not Is_Object_Reference (Nam)
        and then Nkind (Nam) /= N_Function_Call
        and then (Nkind (Nam) /= N_Type_Conversion
                    or else not Is_Tagged_Type (Entity (Subtype_Mark (Nam))))
      then
         if Nkind (Nam) = N_Type_Conversion then
            Error_Msg_N
              ("renaming of conversion only allowed for tagged types", Nam);
         else
            Error_Msg_N ("expect object name in renaming", Nam);
         end if;

The fix is clear, we just need to add an explicit check for
E_Enumeration_Literal, and it got forgotten (because it is easy
to forget, and of course because out of the thousands of people using
GNAT, no one noticed it yet :-)

Now we could have made all enumeration literal references look like
real function calls, but they we would have another set of special
casing.

Oh well, this is by no means the oddest corner in the language :-)






  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
1997-05-16  0:00   ` Robert Dewar [this message]
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         ` Robert A Duff
1997-05-30  0:00           ` Matthew Heaney
1997-05-31  0:00             ` Robert A Duff
1997-05-30  0:00         ` Samuel Mize
  -- 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   ` 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   ` 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