Created
May 3, 2012 20:20
-
-
Save flyx/2588988 to your computer and use it in GitHub Desktop.
Example package where a "protected" scope would be nice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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