comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Exclude parts of a package
Date: Fri, 6 Dec 2013 13:27:53 -0800 (PST)
Date: 2013-12-06T13:27:53-08:00	[thread overview]
Message-ID: <4152aa2a-ad91-4cac-a5ad-30f6e7544647@googlegroups.com> (raw)
In-Reply-To: <52a2382a$0$7939$2c885b36@post.eweka.nl>

On Friday, December 6, 2013 1:48:43 PM UTC-7, Felix Krause wrote:
> 
> This is an interesting approach, but in my case, that would lead to 
> massive code duplication because I don't really have child packages to 
> choose from (same goes for having multiple spec files). I rather need 
> to add or exclude subroutines of one package. Moving it to a child 
> package will not work because it needs to be a primitive operation of a 
> tagged type defined in the original package.

Easy enough solution:
1) Define everything [all of OpenGL, or at least portion-X (X : Types, Functions, etc)] in one big package; for the current version (4.3, IIRC).*
2) Define version-packages which repeat the spec of the appropriate functions and use renames in their body.
3) Use the rename technique given by Brian.

Ex:
--------------------------------------------------

Package Main_Stuff is
  Procedure Bob;  -- Introduced in v.1.
  Procedure Tim;  -- Introduced in v.1.2.
  Procedure Dave; -- Introduced in v.1.3.
  Procedure Bill; -- Introduced in v.1.3.

private
  -- Stubs, to avoid having to provide a body.
  Procedure Bob  is null;
  Procedure Tim  is null;
  Procedure Dave is null;
  Procedure Bill is null;
end Main_Stuff.

-- Def v.1.
private with Main_Stuff;
Package Stuff_1_1 is
  Procedure Bob;
private
  Procedure Bob renames Main_stuff.Bob;
end Stuff_1_1;


-- Def v.1.2.
private with Main_Stuff;
Package Stuff_1_2 is
  Procedure Bob;
  Procedure Tim;
private
  Procedure Bob renames Main_stuff.Bob;
  Procedure Tim renames Main_Stuff.Tim;
end Stuff_1_2;

---- Brian's renaming trick:
with Stuff_1_2;
package Stuff renames Stuff_1_2;

---- Client code:
with Stuff;
procedure Do_Stuff is --....

-------------------------------------------------------------------
* In my OpenGL binding TAO-GL my plan was/is similar to this except
  the bingings query opengl for parameters and build the types from
  the results (ie NUMBER_OF_LIGHTS) via generic instantiation, then
  that would instantiate the functions (ensuring the functions) are
  not called w/ inappropriate parameters.

* TAO-GL: https://github.com/OneWingedShark/TAO-GL
  NOTE:   GitHub version at the state *before* I decided
          to make the Functions package generic.

  reply	other threads:[~2013-12-06 21:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 20:13 Exclude parts of a package Felix Krause
2013-12-06  1:58 ` gautier_niouzes
2013-12-06  7:51 ` Chris Moore
2013-12-06  8:04 ` playerdark
2013-12-06 11:14 ` Brian Drummond
2013-12-06 11:14 ` Brian Drummond
2013-12-06 11:41 ` Brian Drummond
2013-12-06 20:48   ` Felix Krause
2013-12-06 21:27     ` Shark8 [this message]
2013-12-07  8:41       ` Felix Krause
2013-12-07 11:55         ` Brian Drummond
2013-12-08 20:00 ` Stephen Leake
2013-12-12 14:30   ` Marius Amado-Alves
2013-12-13 13:16     ` Felix Krause
2013-12-13 16:17     ` Stephen Leake
2014-01-02 15:06       ` Marius Amado-Alves
2014-01-02 15:07       ` Marius Amado-Alves
replies disabled

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