comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Elemantary Ada question
Date: 2000/11/28
Date: 2000-11-28T00:00:00+00:00	[thread overview]
Message-ID: <900kgs$t6l$1@nnrp1.deja.com> (raw)
In-Reply-To: 900bgt$i6t$1@news.uit.no

In article <900bgt$i6t$1@news.uit.no>,
  Reinert.Korsnes@npolar.no wrote:
> In article <slrn927ai8.tq.lutz@taranis.iks-jena.de>,
>  lutz@iks-jena.de (Lutz Donnerhacke) writes:
> >* Reinert Korsnes wrote:
> >>Can anybody explain me why "A : Float" conflicts
> >>with the declaration:  "type E1 is (a, b, c);" ?
> >
> >Ada is case-in-sensitive.
>
> Ok, let A be a possible value of a variable of type E1
> (let say "type E1 is (A, B, C)").
> And A is a variable name.
>
> Where is the conflict ?

If you are saying that in many cases where you would write "A", its type
could theoreticly be figured out by the context of the statement, then
you are right. However, its pretty easy to construct examples where it
couldn't. What matters here to you isn't what's theoreticly possible for
a compiler to do, but what Ada allows you to do.

In Ada, reusing an Identifier for multiple objects can cause one of two
basic situations; hiding or overloading (in truth, there's a few more,
but we'll ignore those situations for now). "Overloading" is where both
objects exist simultaniously and the compiler will figure out which was
intended from context at compile time. Overloading is only allowed for
subprograms (functions and procedures) with different parameter
profiles, and enumeration literals.

Any other time an indentifier is reused, it should cause hiding; the
later declaration "hides" the earlier one for the entirety of its scope.
This implies that they can't be declared at the same scope (otherwise,
there's no point to the earlier declaration).

Now in your case, then enumeration literal "A" could be overloaded, if
your other "A" were a subprogram or enumeration literal. But since your
other "A" is just a variable declation, this must be a hiding situation.
But it can't be a hiding situation because they are both declared at the
same scope. Therefore its illegal.

Now this was a very informal (read: wrong in many details) treatment of
the subject. If you want to go over the actual legaleese rules involved,
see 8.3 of the LRM (available online at
http://www.adapower.com/rm95/arm95_128.html#SEC128 )


--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  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 [this message]
2000-11-28  0:00     ` Mats Weber
2000-11-28  0:00 ` Robert A Duff
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