comp.lang.ada
 help / color / mirror / Atom feed
From: Philip Anderson <phil.anderson@amsjv.com>
Subject: Re: casecrash: language lawyers: C'mon!
Date: Wed, 18 Jul 2001 10:36:37 +0100
Date: 2001-07-18T10:36:37+01:00	[thread overview]
Message-ID: <3B5558A5.716BF610@amsjv.com> (raw)
In-Reply-To: 3b553588$1@pull.gecm.com

Martin Dowie wrote:
> 
> I think what the original poster is getting at is that it
> would seem perfectly obvious that the case statement is
> referring to the data object called 'H' rather than the
> enumerate 'H', so why can't the language be defined to
> spot this case?

That I think was his question.  But it's not actually the problem the
compiler found, which was the illegal declaration of the object H
(because it is a homograph of the enumeration H).

And that rule is IMHO well-founded, since there are contexts when
writing H would be ambiguous.


Nearer to the original question would be the following:

with Ada.Text_Io; use Ada.Text_Io;
procedure Casecrash is

   package Local is
      type Record_Type is (A, B, C, D, E, F, G, H, I, J, K, L, Unknown);
   end Local;

   use Local;

   type Header is
      record
         Id_Letter : Record_Type := Unknown;
      end record;

   H : Header;

begin
   case H.Id_Letter is
      when A =>
         Put ("a");
      when H =>
--H is not static [RM_95 3.8.1(8); 5.4(5)]
--H is not a value of Record_Type
         Put ("h"); -- H conflict, name clash?
                    -- no context resolution?
      when others =>
         Put ("*");
      end case;
end Casecrash;

since H the enumeration literal has been overriden by the H the object,
although the (Rational Apex) compiler is happy with A in this context. 
RM 8.4(10) seems to apply here.


-- 
hwyl/cheers,
Philip Anderson
Alenia Marconi Systems
Cwmbr�n, Cymru/Wales



  reply	other threads:[~2001-07-18  9:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-17 12:58 casecrash: language lawyers: C'mon! Peter Hermann
2001-07-18  3:43 ` John R. Strohm
2001-07-18  7:18   ` Martin Dowie
2001-07-18  9:36     ` Philip Anderson [this message]
2001-07-19 21:39   ` Robert Dewar
2001-07-19 21:37 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2001-07-18  9:09 Peter Hermann
2001-07-18 20:57 ` Tucker Taft
2001-07-19  8:57   ` Peter Hermann
replies disabled

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