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,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-19 14:42:07 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.mesh.ad.jp!sjc-peer.news.verio.net!news.verio.net!iad-read.news.verio.net.POSTED!not-for-mail From: Dr Nancy's Sweetie Subject: Non-Stub In Inner Scope? Newsgroups: comp.lang.ada Organization: Rowan University User-Agent: tin/1.4.4-20000803 ("Vet for the Insane") (UNIX) (IRIX/6.2 (IP22)) Message-ID: Date: Sat, 19 May 2001 21:42:05 GMT NNTP-Posting-Host: 150.250.128.42 X-Complaints-To: abuse@verio.net X-Trace: iad-read.news.verio.net 990308525 150.250.128.42 (Sat, 19 May 2001 21:42:05 GMT) NNTP-Posting-Date: Sat, 19 May 2001 21:42:05 GMT Xref: archiver1.google.com comp.lang.ada:7651 Date: 2001-05-19T21:42:05+00:00 List-Id: 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