comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: decomposing large packages
Date: Wed, 8 Jan 2020 13:41:18 -0800 (PST)
Date: 2020-01-08T13:41:18-08:00	[thread overview]
Message-ID: <1aa6c82f-5f13-4319-86e9-5464ae8d92c7@googlegroups.com> (raw)
In-Reply-To: <dad5cd25-5eca-499c-bb24-7441eb3b3c33@googlegroups.com>

On Wednesday, January 8, 2020 at 8:56:48 AM UTC-7, mario.b...@gmail.com wrote:
> 
> Now procedure n must be visible from inside package P. How can I accomplish that?

RENAMES.

-------------------
-- P (Spec)
package P is
 type thing is ...
 procedure m (value : in thing);
 procedure n (value : in thing; temp : in natural);
end package P; 

-------------------
-- S1 (Spec)
package S1 is
 procedure n (value : in thing; temp : in natural);
end package S1;

-------------------
-- P (Body)
with S1;
package body P is
 procedure m (value : in thing) is ...
 procedure n (value : in thing; temp : in natural) renames S1.n;
end P;

> I played with child units but did not get what I wanted. The parent P unit must see the procedures and functions of the child units P.S1, P.S2, ... but the compiler complains that procedure n is not defined for type thing in P.

Here's how you CAN do something like that, given the above specs:
-------------------
-- P.Sn (Spec)
Procedure Sn(value : in thing; temp : in natural);

-------------------
-- P (Body)
with P.Sn;
package body P is
 procedure m (value : in thing) is ...
 procedure n (value : in thing; temp : in natural) renames P.Sn;
end P;


> Thanks for your help in advance.

One thing you could do here is nested+separate units. Given
-------------------
-- P (Spec)
package P is
 type thing is ...
 procedure m (value : in thing);
 procedure n (value : in thing; temp : in natural);
private
 -- Internals could be moved to the top of P's BODY.
 package Internals is
   procedure m (value : in thing);
   procedure n (value : in thing; temp : in natural);
 end Internals;
end P;


-------------------
-- P (Body)
package body P is
 procedure m (value : in thing)                    renames Internals.m;
 procedure n (value : in thing; temp : in natural) renames Internals.n;

  package body Internals is separate;
end P;

-------------------
-- P.Internals (Body)
-- File p-internals.adb
Separate (P)
Package Body Internals is
 procedure m (value : in thing) is
  Begin
   -- implementation.
   null;
  End m;
 
 procedure n (value : in thing; temp : in natural) is
  Begin
    -- implementation.
   null;
  End n;

End Internals;

      parent reply	other threads:[~2020-01-08 21:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-08 15:56 decomposing large packages mario.blunk.gplus
2020-01-08 16:36 ` Dmitry A. Kazakov
2020-01-09  8:25   ` mario.blunk.gplus
2020-01-09  8:58     ` Dmitry A. Kazakov
2020-01-09 18:24       ` G. B.
2020-01-10 20:03         ` mario.blunk.gplus
2020-01-08 16:45 ` Simon Wright
2020-01-09  8:28   ` mario.blunk.gplus
2020-01-09 17:43     ` Simon Wright
2020-01-10 20:00       ` mario.blunk.gplus
2020-01-08 21:41 ` Shark8 [this message]
replies disabled

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