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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d5cbc012ac099061 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-19 15:01:05 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!headwall.stanford.edu!news-out.nibble.net!news-in.nibble.net!telocity-west!TELOCITY!newsrump.sjc.telocity.net!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: Subject: Re: Non-Stub In Inner Scope? MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: X-Trace: NjMgTm9BdXRoVXNlciBURUxPQ0lUWS1SRUFERVJTIDIxNi4yMjcuNDcuNDkgIFNhdCwgMTkgTWF5!IDIwMDEgMTU6MDE6MDMgUERU X-Abuse-Info: Please forward ALL headers when reporting abuse. X-Complaints-To: abuse@telocity.net NNTP-Posting-Date: Sat, 19 May 2001 15:01:03 PDT Date: Sat, 19 May 2001 17:01:07 -0500 Xref: archiver1.google.com comp.lang.ada:7652 Date: 2001-05-19T17:01:07-05:00 List-Id: Just move the stub outside of the subprogram which now encloses it. It will be in the package body and visible to all subprograms which follow its declaration, but it will not be visible to clients of the package, because it doesn't appear in the package spec. "Dr Nancy's Sweetie" wrote in message news:NMBN6.5769$DW1.255373@iad-read.news.verio.net... > > I'm having trouble with the problem of separate compilation. If I > try this: > > > with Ada.Text_Io; > package body Example is > procedure Put_Line(Text: String) is > function Wont_Work(Text: String) return String is separate; > begin > Ada.Text_Io.Put_Line(Wont_Work(Text)); > end Put_Line; > end Example; > > > GNAT gets to the function Wont_Work() and says: > > example.adb:4:07: stub cannot appear in an inner scope > > > I can just move the stub for Wont_Work() into the package spec, but it > doesn't properly belong there: that would make it "global" to all the > parts of the package, and it is only needed in this one place. > > I see two obvious solutions: > > 1) The C-style solution, which is to move the stub into the package spec, > and thus have it accessable by every part of the package. I don't > like this because one reason to use Ada is that you can have local > functions. > > 2) The Pascal-style solution, which is to cram the whole function (and > it's really long, and there are several of them) into the declaration > section of the Put_Line() procedure. I don't like this one, because > because it means that between the line "procedure Put_Line(...) is" > and the associated "begin", I would have almost 500 lines of code. > > Both solutions also have the problem that I'd have to have the body of > Wont_Work() in the example.adb file, making it impossible to do separate > compilation. There are several functions that go along with Wont_Work(), > and they're pretty long. They are debugged and stable at this point, > which is why I wanted to move them out; the rest of the package is still > in flux. Recompiling that code over and over can consume a lot of time. > > Is it possible in Ada to write a package such that the source for its > functions and procedures is in more than one file? > > Or am I just going about this in some non-Ada-y fashion? (I confess > to being new at this.) > > > Darren Provine ! kilroy@copland.rowan.edu ! http://www.rowan.edu/~kilroy > "I use not only all the brains I have, but all those I can borrow as well." > -- Woodrow Wilson