comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Suggestions needed to split a package
Date: Fri, 24 May 2019 14:21:12 -0700 (PDT)
Date: 2019-05-24T14:21:12-07:00	[thread overview]
Message-ID: <7cd141fd-3bed-44cd-a09e-9473b18eb7d9@googlegroups.com> (raw)
In-Reply-To: <qc9k0q$tah$1@franka.jacob-sparre.dk>

On Friday, May 24, 2019 at 2:26:04 PM UTC-6, Randy Brukardt wrote:
> "Björn Lundin" wrote in message 
> news:qc9595$ime$1...
> > Den 2019-05-24 kl. 17:49, skrev A. Cervetti:
> >> A package in the program I am writing is getting too long.
> >> So I thought it would be a good idea to split it.
> >>
> >> The package is here: 
> >> https://github.com/andreacervetti/ada-virt-monitor/tree/master/avm/src/monitor 
> >> (files monitor-structures.ad*).
> >>
> >> My problems are:
> >> I'd like to avoid forcing clients of the package to "with" too many 
> >> modules.
> >> I want keep private types private.
> >
> > If it is only file size that is your concern, you
> > can look at moving some functions via 'separate' to other files.
> > It does not change your structure, and clients of
> > the package does not know -> not more withs than current solution
> 
> Yes, although if there are a lot of small subprograms, it's not very 
> effective as you would end up with a *lot* of files (making it hard to find 
> things and slowing compilation). And you can't make overloaded subprograms 
> separate (the names have to be unique).

The way I've gotten around this is by putting these small subprograms in a nested-package within the body, making *that* package separate, and using renames.

Package Public is
  Type T1 is private;
  Procedure P1;
  Procedure P2;
  --...
End Public;

Package Body Public is
  Package Internal is
    Procedure P1;
    Procedure P2;
  End Internal;
  Package Body Internal is Separate;
  
  Procedure P1 renames Internal.P1;
  Procedure P2 renames Internal.P2;
End Public;

-------
As to making overloaded subprograms separate, is there a way to correct this? That, plus [TTBOMK] not being able to overload subprograms in the library hierarchy seem to be fairly related and could arguably make maintenance easier.

e.g. We can't have both
function Ada.Strings.Equal_Case_Insensitive (Left, Right : String) return Boolean;
function Ada.Strings.Equal_Case_Insensitive (Left, Right : Wide_Wide_String) return Boolean;

      reply	other threads:[~2019-05-24 21:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 15:49 Suggestions needed to split a package A. Cervetti
2019-05-24 16:14 ` Björn Lundin
2019-05-24 20:26   ` Randy Brukardt
2019-05-24 21:21     ` 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