From: Simon Wright <simon@pushface.org>
Subject: Re: Parent/child dependencies and internal library units
Date: Wed, 23 Jul 2014 17:47:55 +0100
Date: 2014-07-23T17:47:55+01:00 [thread overview]
Message-ID: <ly38dsrphg.fsf@pushface.org> (raw)
In-Reply-To: lqoncd$ue7$1@speranza.aioe.org
Victor Porton <porton@narod.ru> writes:
> I noticed that child units depend on their parents.
>
> As such making parent dependent on a child makes a dependency loop.
>
> Before noting this feature of Ada language, I thought parent units could be
> implemented based on their child units, but that does not work, because
> making parents dependent on children is a circular dependency.
>
> So, my question:
>
> What is a good way to create "internal" or "implementation" units for a
> unit? Should I create a *.Internal.* hierarchy of packages?
I dare say there are uses which could make this not work (possibly
involving initialisation of objects in specs via function calls, leading
to access-before-elaboration) but you can make a parent body depend on a
child spec.
If the implementation is meant to be hidden from users outside the
parent, consider using private child packages.
package Hierarchy is
procedure Tell;
end Hierarchy;
private package Hierarchy.Internal is
procedure Tell;
end Hierarchy.Internal;
with Ada.Text_IO;
package body Hierarchy.Internal is
procedure Tell is
begin
Ada.Text_IO.Put_Line ("Hierarchy.Internal");
end Tell;
end Hierarchy.Internal;
with Ada.Text_IO;
with Hierarchy.Internal;
package body Hierarchy is
procedure Tell is
begin
Ada.Text_IO.Put_Line ("Hierarchy");
Internal.Tell;
end Tell;
end Hierarchy;
procedure Hierarchy.Main is
begin
Tell; -- this is Hierarchy.Tell
end Hierarchy.Main;
next prev parent reply other threads:[~2014-07-23 16:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 16:20 Parent/child dependencies and internal library units Victor Porton
2014-07-23 16:40 ` mockturtle
2014-07-23 16:47 ` Simon Wright [this message]
2014-07-23 16:48 ` Adam Beneschan
2014-07-23 18:37 ` Stefan.Lucks
2014-07-23 21:31 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox