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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c40a80666be78948 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Elemantary Ada question Date: 2000/11/28 Message-ID: <900kgs$t6l$1@nnrp1.deja.com>#1/1 X-Deja-AN: 698714974 References: <9008uq$hmi$1@news.uit.no> <900bgt$i6t$1@news.uit.no> X-Http-Proxy: 1.0 x57.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Nov 28 15:55:11 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001010 Date: 2000-11-28T00:00:00+00:00 List-Id: In article <900bgt$i6t$1@news.uit.no>, Reinert.Korsnes@npolar.no wrote: > In article , > 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.