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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6a9844368dd0a842,start X-Google-Attributes: gid103376,public From: David Morton Subject: seperate keyword and seperate compilation with Gnat? Date: 1996/07/02 Message-ID: <31D95D93.28D8D15B@jinx.sckans.edu>#1/1 X-Deja-AN: 163320679 content-type: text/plain; charset=us-ascii organization: student mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 3.0b3 (X11; I; Linux 2.0.0 i486) Date: 1996-07-02T00:00:00+00:00 List-Id: I've been working with John Herro's AdaTutor program on Linux, and gnat. He uses the keyword seperate a lot, to make the assignment procedure in a seperate file, ie, in file foo.adb (the test file) procedure bar is seperate; then in file foo-bar.adb seperate(foo) (the assignment file) procedure bar is ... He argues that the file foo.adb should be able to be compiled, seperately, since the specification is there, even though the actual procedure body has not been written. I'm inclined to believe that he's right, but gnat refuses to cleanly compile unless the file foo-bar.adb exists. Well, here's a snip from an email message he sent me, which explains it better than I can: from John Herro: > "It's an important part of Ada. A separate subprogram (procedure or >function) can be part of a package or part of another subprogram. For >example, we can improve on the following "Pascal style" code: >procedure Main is > ... > procedure Sub(I : in Integer) is separate; > ... > begin > ... > end Sub; >begin > ... > Sub(3); > ... >end Main; >The disadvantage of the above is that, if you make any changes to Sub, you >have to recompile Main. But if you write the following in two files: >procedure Main is > ... > procedure Sub(I : in Integer) is separate; >begin > ... > Sub(3); > ... >end Main; > >separate (Main) >procedure Sub is > ... >begin > ... >end Sub; >then we can change the second file and recompile it without having to >recompile Main. Note that Main contains the specification for Sub. That is, >the line > procedure Sub(I : in Integer) is separate; >tells the compiler that Sub takes one input parameter of type Integer. > That's all the information the compiler needs to compile the call to Sub: > Sub(3); >The body of Sub can be compiled later - any time before linking. Sub can >still "see" the declarations above it in the main program; it's as if Sub >were cut out and "pasted" where the main program says "is separate." > I've taken advantage of this feature of Ada in several Outside >Assignments, where the test driver is the main program in one file, and the >function that the student is writing is a separate subprogram in another >file. " Could anyone explain why gnat does not allow this? -- David Morton mailto:dmorton@jinx.sckans.edu // If you use Netscape 2.0, 205 College, Winfield, KS 67156 // you can click on the mailto: part to reply! (HINT, HINT) :)