comp.lang.ada
 help / color / mirror / Atom feed
* Non-Stub In Inner Scope?
@ 2001-05-19 21:42 Dr Nancy's Sweetie
  2001-05-19 22:01 ` David C. Hoos, Sr.
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dr Nancy's Sweetie @ 2001-05-19 21:42 UTC (permalink / raw)



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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-05-20 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-19 21:42 Non-Stub In Inner Scope? Dr Nancy's Sweetie
2001-05-19 22:01 ` David C. Hoos, Sr.
2001-05-19 23:08   ` Robert A Duff
2001-05-20 10:50   ` RPrice9979
2001-05-20  3:15 ` Jeffrey Carter
2001-05-20 12:29 ` Marc A. Criley
2001-05-20 20:07   ` David C. Hoos, Sr.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox