comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Elemantary Ada question
Date: 2000/11/28
Date: 2000-11-28T00:00:00+00:00	[thread overview]
Message-ID: <wcck89ojdyv.fsf@world.std.com> (raw)
In-Reply-To: 9008uq$hmi$1@news.uit.no

reinert@ola.npolar.no (Reinert Korsnes) writes:

> Can anybody explain me why "A : Float" conflicts
> with the declaration:  "type E1 is (a, b, c);" ?

Enumeration literals are overloadable, but variables are not
overloadable.  You are not allowed to have a non-overloadable A if there
is some other A in the same scope (even if the other one is
overloadable).

The exact rules are in chapter 8 of the RM.  It says that two
declarations with the same name are "homographs" if one or both are
non-overloadable.  Also, if both are overloadable, and have the same
parameter and result types (where the enumeration literal A is like a
parameterless function returning type E1).  It is illegal to have two
homographs in the same "declarative region".

Or perhaps you are asking why was the language defined that way.
Well, variable names could be overloadable, and the language rules
would work just fine.  The above would be legal, and things like

    X: E1 := A;

would resolve to the right A.  Things like "if A = A..." would be
ambiguous, and therefore illegal.

- Bob




  parent reply	other threads:[~2000-11-28  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-28  0:00 Elemantary Ada question Reinert Korsnes
2000-11-28  0:00 ` Lutz Donnerhacke
2000-11-28  0:00   ` Reinert Korsnes
2000-11-28  0:00     ` Lutz Donnerhacke
2000-11-28  0:00     ` Ted Dennison
2000-11-28  0:00     ` Mats Weber
2000-11-28  0:00 ` Robert A Duff [this message]
2000-11-28  0:00 ` Scott Ingram
replies disabled

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