Created
May 23, 2012 13:59
-
-
Save Julio-Guerra/2775380 to your computer and use it in GitHub Desktop.
Separating "interface constants" (types, package renames & constants values) from the interface declaration in Ada using sibling packages
This file contains hidden or 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
with Misc.Interface; use Misc.Interface; | |
with Misc.Types; use Misc.Types; | |
procedure Main is | |
X : A := A'(Bar); -- separate type definitions ok | |
begin | |
F(X); | |
F(Cst); -- separate constant values definitions ok | |
Rename_Me.Put_Line(A'Image(X)); -- separate package renames ok | |
end Main; |
This file contains hidden or 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
with Misc.Constants; use Misc.Constants; | |
-- Interface and Types are sibling packages which is the only | |
-- way not to get a circular reference error (by keeping the | |
-- interface is misc.ads which would be the parent package of | |
-- Constants). | |
-- when trying to separate part of the specification file. | |
package Misc.Interface is | |
procedure F(X : A); | |
end Misc.Types; |
This file contains hidden or 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
with Ada.Text_IO; -- for example | |
package Misc.Constants is | |
-- Type definition | |
type A is (Foo, Bar); | |
-- Package rename | |
package Rename_Me renames Text_IO; | |
-- Constant value | |
Cst : constant A := A'(Foo); | |
end Misc.Constants; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment