comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Non-Stub In Inner Scope?
Date: Sat, 19 May 2001 17:01:07 -0500
Date: 2001-05-19T17:01:07-05:00	[thread overview]
Message-ID: <z2CN6.660$ce.1111604@newsrump.sjc.telocity.net> (raw)
In-Reply-To: NMBN6.5769$DW1.255373@iad-read.news.verio.net

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" <kilroy@copland.rowan.edu> 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




  reply	other threads:[~2001-05-19 22:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-19 21:42 Non-Stub In Inner Scope? Dr Nancy's Sweetie
2001-05-19 22:01 ` David C. Hoos, Sr. [this message]
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.
replies disabled

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