comp.lang.ada
 help / color / mirror / Atom feed
From: And838N@netscape.net
To: comp.lang.ada@ada.eu.org
Subject: visibility
Date: Wed, 04 Jun 2003 18:12:05 -0400
Date: 2003-06-04T18:12:05-04:00	[thread overview]
Message-ID: <mailman.9.1054764760.11750.comp.lang.ada@ada.eu.org> (raw)

Ok, here's another question.  I'll provide some background information first.

Let us say that there is a procedure in an .adb file that is not in a 
package and it looks something like the following:

----------------------
with
ada.text_io,
ada.integer_text_io,
ada.strings.unbounded;

use
ada.text_io,
ada.integer_text_io,
ada.strings.unbounded;

procedure x is
    astring: unbounded_string := "hello world";
    somenumber: integer := 0;
begin
    somenumber := count(astring, to_set(' '));
    put(somenumber); 
end x;
-----------------------

Now we go compile it and GNAT gives me a message that says there is 
more than one "count" and that I have to specify, by using the full 
package name before the word count, in order to specify which count I
want.  Which isn't so bad, yet...

So out of curiosity I look at the version of count inside ada.text_io 
and compare it to the version of count inside ada.strings.unbounded.  
Turns out the count inside ada.text_io isn't a "procedure" at all, it's 
a variable type.

So I investigate further.  The author of Ada as a second language, 
Norman Cohen provided a chapter on scope and visiblity.  In that 
chapter (actually an appendix), he says that one of the only times 
there will be a visibility problem is when a variable type and a 
procedure have the same name.  

It is hard for me to accept that Ada (GNAT) can't tell the difference 
between a variable type and a procedure?  I wouldn't be surprised if 
both counts were procedures or both counts were variable types, having the same "signature".  But a variable type compared to a procedure?  
Does that mean that after a visibility conflict occurs when compiling 
that there is no "signature" checking? Can someone please explain?

Second question related to "with"ing and "use"ing. (I think the first
question might be resolved by re-working my "with"s and "use"s.)
If I "with" ada.strings, that makes it, and it's children "visible" to
my procedure or package?
If so, then I can "use" only the children I want, like fixed, 
unbounded, unbounded_text_io, etcetera?
If so, does the compiler or linker still link in, or for lack of a 
better term "insert" code into my procedure/package for the children I 
didn't "use"?

Thanks,

Andrew

P.S.
How's the word wrap now?



__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455



             reply	other threads:[~2003-06-04 22:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-04 22:12 And838N [this message]
2003-06-05 10:35 ` visibility Preben Randhol
2003-06-05 15:19 ` visibility Frank J. Lhota
     [not found] <009C830A.36D4A463.0015D3EC@netscape.net>
2003-06-07 12:18 ` Visibility David C. Hoos, Sr.
2003-06-08  3:28   ` Visibility Hyman Rosen
2003-06-08 10:20     ` Visibility Frank J. Lhota
2003-06-08 16:18       ` Visibility Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
2003-06-07  8:21 Visibility And838N
2003-06-07 17:29 ` Visibility Jeffrey Carter
2003-06-06  5:15 Visibility christoph.grein
     [not found] <666191F6.00B406DF.0015D3EC@netscape.net>
2003-06-05 15:16 ` visibility David C. Hoos
1992-12-24 11:48 Visibility agate!spool.mu.edu!darwin.sura.net!Sirius.dfn.de!chx400!sicsun!disuns2!lg
1992-12-24  2:16 Visibility Richard Pattis
1992-12-23 23:35 Visibility agate!spool.mu.edu!uwm.edu!cs.utexas.edu!torn!nott!netfs!news
replies disabled

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