comp.lang.ada
 help / color / mirror / Atom feed
* "shadow" package hierarchy using renaming of child packages
@ 2013-06-30  7:00 Oliver Kellogg
  2013-06-30 20:43 ` AdaMagica
  2013-07-01  8:21 ` AdaMagica
  0 siblings, 2 replies; 9+ messages in thread
From: Oliver Kellogg @ 2013-06-30  7:00 UTC (permalink / raw)


Hi,

I was quite amazed to find that GNAT lets me rename a child package
of one hierarchy to a child package of a different hierarchy (i.e. having a different root.)

Does this work on other compilers too?

Thanks,

   Oliver


-- file: foo.ads (original root package)
package Foo is
   type T is new Integer;
end Foo;

-- file: foo-child.ads
package Foo.Child is
   function Create return T;
end Foo.Child;

-- file: foo-child.adb
package body Foo.Child is
   function Create return T is
   begin
      return 0;
   end Create;
end Foo.Child;

-- file: shadow.ads (a different root package)
with Foo;
package Shadow is
   subtype T is Foo.T;
   type Other_Stuff is range 999 .. 1000;
end Shadow;

-- file: shadow-child.ads
with Foo.Child;
package Shadow.Child renames Foo.Child;

-- file: test_shadow.adb
with Shadow.Child;
procedure Test_Shadow is
   I : Shadow.T := Shadow.Child.Create;
begin
   null;
end Test_Shadow;

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-07-01 16:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-30  7:00 "shadow" package hierarchy using renaming of child packages Oliver Kellogg
2013-06-30 20:43 ` AdaMagica
2013-07-01  1:34   ` Shark8
2013-07-01  5:46     ` J-P. Rosen
2013-07-01 16:31       ` Adam Beneschan
2013-07-01  8:29   ` Oliver Kellogg
2013-07-01  9:37     ` AdaMagica
2013-07-01 11:14       ` Oliver Kellogg
2013-07-01  8:21 ` AdaMagica

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