comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Position of "use"
Date: Tue, 15 Jul 2014 09:36:17 +0200
Date: 2014-07-15T09:36:12+02:00	[thread overview]
Message-ID: <53c4d9ec$0$6658$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <lq2fpk$dqu$1@speranza.aioe.org>

On 15.07.14 07:56, anon@att.net wrote:
> The "With_Clause"
> --  scope is defined in RM 10.1.2 (5), and does suggest that the
> --  "With_Clause" for a multiple compilation files are global.

10.1.2 (5) refers to a declaration (such as a package declaration),
and to this declaration's declarative region.

10.1.1 lists compilation_unit as either a library_item or a subunit.
(For example, a package spec, or a separate procedure body.)

8.1, at which Adam Beneschan has hinted, expounds declarative_region,
mentioned in 10.1.2.
For any such declaration, as I understand it, a with_clause is in scope of
the corresponding declarative_region, but nowhere else. So, for example,
a with_clause above a package spec will be in scope of a package spec,
its body, a separate procedure body (subunit) declared somewhere in
the package, and children of the package.

But, for example, another package (other than children of the first,
or subunits) that happens to be declared in the same file establishes
another declarative region. Any with_clause, then, that is atop any
prior declarative region is not in scope of this package's declarative
region.


GNAT's gnatchop will confirm this when run on the two units below placed
in the same one file. I do get a warning about redundant with clauses,
when the compiler analyses the resulting unit associated with the name Foo.
I do get two files, foo.adb and bar.adb. But gnatchop does not place
a with_clause ("with Ada.Text_Io") in bar.adb.  Correspondingly, any
use_clause placed anywhere in the declarative region of Bar will not
work. Nor will Ada.Text_Io.Put_Line name a procedure, as Ada.Text_IO will
not have been with-ed there.

with Ada.Text_Io;
with Ada.Text_Io ;

procedure Foo is
begin
    Ada.Text_Io.Put_Line ("Foo");
end Foo;

procedure Bar is
begin
    Ada.Text_Io.Put_Line ("Bar");
end Bar;



  reply	other threads:[~2014-07-15  7:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-05  6:43 Position of "use" Victor Porton
2014-07-05  7:12 ` J-P. Rosen
2014-07-07 16:45   ` Adam Beneschan
2014-07-07 17:08     ` Pascal Obry
2014-07-07 17:40       ` Peter Chapin
2014-07-07 19:17       ` Adam Beneschan
2014-07-08  5:26     ` J-P. Rosen
2014-07-08 15:32       ` Adam Beneschan
2014-07-08 19:30 ` Adam Beneschan
2014-07-08 22:39   ` Victor Porton
2014-07-09 10:36 ` anon
2014-07-09 15:14   ` Adam Beneschan
2014-07-10  1:27     ` anon
2014-07-10  9:50       ` AdaMagica
2014-07-10 13:10         ` J-P. Rosen
2014-07-10 15:57           ` Adam Beneschan
2014-07-10 17:47             ` Tero Koskinen
2014-07-10 19:15           ` Jeffrey Carter
2014-07-15  5:56         ` anon
2014-07-15  7:36           ` Georg Bauhaus [this message]
2014-07-15 17:01             ` Simon Wright
2014-07-15 17:23               ` Jeffrey Carter
2014-07-15 19:44                 ` Simon Wright
2014-07-15 17:47               ` G.B.
2014-07-15 17:51               ` Adam Beneschan
2014-07-15 20:04                 ` Simon Wright
2014-07-16  7:19                 ` anon
2014-07-10 15:54       ` Adam Beneschan
replies disabled

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