From: Oliver Kellogg on 4 Mar 2010 00:37 Referring back to http://groups.google.com/group/comp.lang.ada/msg/c14a79f7d21f5ebf , On Mar 29 2002, 2:05 pm, Oliver Kellogg wrote: > Sergey Koshcheyev <serk...(a)hotmail.com> wrote: > > Just a quick idea - maybe using "is separate" in some right places > > would solve it? Like having the spec of A.B.Impl inside A.B, and > > having the body separate. > > That's definitely possible, but still only a workaround solution. I have to correct myself. It's not so definitely possible: -- file: a.ads package A is -- module A package B is -- interface B package Impl is procedure X; end Impl; end B; end A; -- file: a.adb package body A is package body B is -- Implementation for interface B, -- body to be provided by user package body Impl is separate; end B; end A; $ gcc -c a.adb a.adb:6:07: stub cannot appear in an inner scope
From: Admin - Do Not Email on 4 Mar 2010 09:55 On Mar 4, 12:37 am, Oliver Kellogg <okell...(a)users.sourceforge.net> wrote: > Referring back tohttp://groups.google.com/group/comp.lang.ada/msg/c14a79f7d21f5ebf, > > Hello CLA, > > How come child packages are only possible for library level packages? > > I now encountered a situation where I'd like to create a child > package of a nested package: > > -- file: pkg.ads > package Pkg is > package Nested is > type Object is tagged null record; > end Nested; > end Pkg; > > -- file: pkg-nested-child.ads > package Pkg.Nested.Child is > type Derived is new Object with null record; > end Pkg.Nested.Child; I can't tell you *why* that's not allowed, but your supposition about additional work for the compiler makes sense. In this case, would the following work for you?: -- file: nested_child.ads with Pkg; use Pkg; use Pkg.Nested; package Nested_Child is type Derived is new Object with null record; end Nested_Child;
From: Adam Beneschan on 4 Mar 2010 11:12 On Mar 3, 9:37 pm, Oliver Kellogg <okell...(a)users.sourceforge.net> wrote: > Referring back tohttp://groups.google.com/group/comp.lang.ada/msg/c14a79f7d21f5ebf, > > On Mar 29 2002, 2:05 pm, Oliver Kellogg wrote: > > > Sergey Koshcheyev <serk...(a)hotmail.com> wrote: > > > Just a quick idea - maybe using "is separate" in some right places > > > would solve it? Like having the spec of A.B.Impl inside A.B, and > > > having the body separate. > > > That's definitely possible, but still only a workaround solution. > > I have to correct myself. It's not so definitely possible: > > -- file: a.ads > package A is -- module A > package B is -- interface B > package Impl is > procedure X; > end Impl; > end B; > end A; > > -- file: a.adb > package body A is > package body B is > -- Implementation for interface B, > -- body to be provided by user > package body Impl is separate; > end B; > end A; > > $ gcc -c a.adb > a.adb:6:07: stub cannot appear in an inner scope You can do it if you make B separate: package body A is package body B is separate; end A; separate(A) package body B is package body Impl is separate; end B; I'm not really familiar with the original problem so I don't know whether this helps you any. -- Adam
|
Pages: 1 Prev: GNAT GPL for LEGO Mindstorms NXT Next: Testing a package's internal details. |