From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,487310d7e1471eac X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: parent package referring to child Reply-To: anon@anon.org (anon) References: <1191997397.865251.322480@d55g2000hsg.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Wed, 10 Oct 2007 19:17:58 GMT NNTP-Posting-Host: 12.64.228.176 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1192043878 12.64.228.176 (Wed, 10 Oct 2007 19:17:58 GMT) NNTP-Posting-Date: Wed, 10 Oct 2007 19:17:58 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:2419 Date: 2007-10-10T19:17:58+00:00 List-Id: Some time package can get too large to handle there are a few ways to handle this in all Ada's spec. The non-standard Ada way is to use "pragma Import" "pragma Export" statements. The standard Ada way is to use the "seperate" paradigm. That is split the FOO package into smaller files and use the "seperate" statement to relink them. To test for errors and build the package use "gnat compile foo.adb" the compile will load and compile all seperate packages that are in FOO package. -- ------------- -- -- File: Foo.ads -- -- ------------- -- package body Foo is procedure Local_Foo ; end Foo ; -- ------------- -- -- File: Foo.adb -- -- ------------- -- package body Foo is -- -- spec for seperate packages and routines -- package Ch10 is -- spec end Ch10 ; package Ch11 is -- spec end Ch11 ; procedure Load ; use Ch10 ; use Ch11 ; -- -- Define children bodies are in external files with name -- PARENT-CHILD.adb -- package body Ch10 is separate ; package body Ch11 is separate ; procedure Load is separate ; -- -- local procedures and those that are visible to the -- outsise -- procedure Local_Foo is ... begin -- Local_Foo ... end Local_Foo ; ... end Foo ; -- ------------------ -- -- File: foo-ch10.adb -- -- ------------------ -- separate (Foo) package body Ch10 is ... end Ch10 ; -- ------------------ -- -- File: foo-ch11.adb -- -- ------------------ -- separate (Foo) package body Ch11 is ... end Ch11 ; -- ------------------ -- -- File: foo-load.adb -- -- ------------------ -- separate (Foo) procedure Load is ... begin -- Load ... end Load ; In <1191997397.865251.322480@d55g2000hsg.googlegroups.com>, eliben writes: >Hello, > >I have a package FOO that encapsulates a large part of the system. Now >I need to add to it a public type (that should be visible by external >code) with a lot of enumerated names (hundreds). I don't want to fill >the spec of FOO with this huge type, so I thought it would be a good >idea to create a subpackage: FOO.Names, and place the type there. > >However, declarations of subprograms in the spec of FOO must refer to >the names from FOO.Names, and Ada 95 won't let me do that because it's >parent referring to child. > >Is there any way to overcome this problem ? Perhaps a different design >that suits the requirement and doesn't go against the Ada standard ? > >Thanks in advance. >