comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Inheritance with Ada types
Date: Tue, 09 Feb 2010 10:11:10 +0100
Date: 2010-02-09T10:11:10+01:00	[thread overview]
Message-ID: <ir8rkh.hqm.ln@hunter.axlog.fr> (raw)
In-Reply-To: <92c90b37-0e9b-49f4-ab37-fbd256ed6f06@k41g2000yqm.googlegroups.com>

Hibou57 (Yannick Duch�ne) a �crit :
> On 9 f�v, 03:16, Bryan <brobinson....@gmail.com> wrote:
> Oops : package and type name share the same name and you there are use
> clause... the use clause is particularly evil here.
Why? The use clause has no effect in this case!

>> $ gnatmake -c parent derived.ads
>> gcc -c derived.ads
>> derived.ads:3:23: subtype mark required in this context
>> derived.ads:3:23: found "Parent" declared at parent.ads:2
> The message refer to
>> package Parent is
> 
>> derived.ads:5:23: subtype mark required in this context
>> derived.ads:5:23: found "Parent" declared at parent.ads:2
> The same as above
> 
> Either rename your packages (like Parents and Deriveds ... although
> the latter is not correct English) 
or use the convention of giving the class name to the package, and some
fixed name like "object" or "instance" to the type. Full rationale for
this notation is available in my paper "A naming convention for classes
in Ada 9X", downloadable from http://www.adalog.fr/publica2.htm

> or drop the use clause and refer to
> your Parent ancestor as Parent.Parent instead.
Of course, you don't need to drop the use clause to write Parent.Parent!

I don't understand why people think that as soon as you have a use
clause, you cannot use full names. If within the scope of a use clause
you don't get what you want, or if you find that in some cases full
names are more readable, by all mean, use full notation!

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  reply	other threads:[~2010-02-09  9:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09  2:16 Inheritance with Ada types Bryan
2010-02-09  2:57 ` Hibou57 (Yannick Duchêne)
2010-02-09  9:11   ` Jean-Pierre Rosen [this message]
2010-02-09 10:19     ` Hibou57 (Yannick Duchêne)
2010-02-09 11:23       ` Jean-Pierre Rosen
2010-02-10  2:47         ` Randy Brukardt
2010-02-09 10:22     ` Hibou57 (Yannick Duchêne)
2010-02-09 15:08 ` Robert A Duff
2010-02-09 23:39   ` Bryan
replies disabled

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