comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Problem with limited with
Date: Sat, 27 Jul 2013 20:21:20 +0100
Date: 2013-07-27T20:21:20+01:00	[thread overview]
Message-ID: <lybo5nstan.fsf@pushface.org> (raw)
In-Reply-To: kt0uo3$3kh$1@dont-email.me

Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> About the only thing you can do with limited with is declare access
> types designating the types in the withed pkg, So of course an Ada
> compiler complains if you try to do anything else. When you avoid
> visible access types, you naturally avoid limited with. This is how
> I've been able to work on large projects (> 1000 pkgs) without a
> single limited with.

I had a project of similar size, in Ada 95 - so limited with wasn't an
option! (I did try the GNAT experimental versions, but each subtle
variant in my code produced a new ICE).

The solution was threefold:

(a) each class (this was code-generated from a UML model using
a Shlaer-Mellor OOA profile) declares a type Instance derived from a
base type

(b) associations (what you would need the limited with for) are
implemented by appropriate access components in the Instance record
(they aren't private, but you're not supposed to use them)

(c) associations between two classes are managed using a third
package. If the House_Management model says

   Association A1:
      each Button Controls one-or-more Lamps
      each Lamp Is_Controlled_By one-or-more Buttons

the generated code will include

   with House_Management.Lamp.Collections;
   with House_Management.Button.Collections;
   with House_Management.Button_To_Lamp.Collections;
   private package House_Management.A1 is

      function Link
        (Controls : Lamp.Handle;
         Is_Controlled_By : Button.Handle)
        return Button_To_Lamp.Handle;

   [...]

      procedure Unlink
        (Button_To_Lamp_Handle : Button_To_Lamp.Handle);

   [...]

      function Controls
        (A_Lamp : Lamp.Handle)
        return Button.Collections.Collection;

   [...]

      function Is_Controlled_By
        (A_Button : Button.Handle)
        return Lamp.Collections.Collection;


  reply	other threads:[~2013-07-27 19:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 19:14 Problem with limited with Simon Wright
2013-07-26 20:49 ` Jeffrey Carter
2013-07-26 22:17   ` Adam Beneschan
2013-07-26 22:25     ` Shark8
2013-07-26 22:35     ` Simon Wright
2013-07-27  0:17     ` Jeffrey Carter
2013-07-27  1:08       ` Adam Beneschan
2013-07-27  8:05         ` Simon Wright
2013-07-27  2:32       ` Shark8
2013-07-27  5:42         ` Jeffrey Carter
2013-07-27 16:00           ` Shark8
2013-07-27 17:13             ` Jeffrey Carter
2013-07-27 19:21               ` Simon Wright [this message]
2013-07-28  2:51               ` Randy Brukardt
2013-07-27  3:55       ` Randy Brukardt
replies disabled

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