Skip to content

Instantly share code, notes, and snippets.

@flyx
Created May 3, 2012 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyx/2588988 to your computer and use it in GitHub Desktop.
Save flyx/2588988 to your computer and use it in GitHub Desktop.
Example package where a "protected" scope would be nice
package Foo is
type A is abstract tagged null record;
-- some functionality A provides
procedure Bar (Object : A);
-- some part of this functionality that depends
-- on the specific child-classes of A
-- this function should not be visible to other
-- packages, but it has to be visible to packages
-- that implement a child class of A.
function Calculate (Object : A) return Integer is abstract;
end Foo;
package body Foo is
procedure Bar (Object : A) is
Var : Integer;
begin
-- do something
-- ...
-- let the specific child class define an implementation of this
Var := Calculate (Object);
-- continue doing something
-- ...
end Bar;
end Foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment