* Newbie Visibility Problem TEXT_IO.INTEGER_IO
@ 2004-06-02 19:37 bm34mailing<<SPAM-SUCKS>>
2004-06-02 19:48 ` Simon Wright
2004-06-03 7:16 ` Dmitry A. Kazakov
0 siblings, 2 replies; 6+ messages in thread
From: bm34mailing<<SPAM-SUCKS>> @ 2004-06-02 19:37 UTC (permalink / raw)
Hi All:
I am very new to Ada and am having a visibility problem that I am not
sure how to get around. I am trying to build the "MostUltimateAnswer"
sample application from the LAW web site (Section 1.2.12).
http://www.scism.sbu.ac.uk/law/Section1/chap2/s1c2p12.html
I have ensured that I copied the source code verbatim (less the line
numbers) and get the following errors:
D:\Projects\Personal\ada>gnatmake -f -u MostUltimateAnswer.adb
gcc -c mostultimateanswer.adb
mostultimateanswer.adb:15:25: "Text_Io" is not visible
mostultimateanswer.adb:15:25: non-visible declaration at a-textio.ads:51
mostultimateanswer.adb:16:08: "Intio" is undefined
mostultimateanswer.adb:47:04: invalid parameter list in call (use -gnatf
for det
ails)
mostultimateanswer.adb:58:04: invalid parameter list in call (use -gnatf
for det
ails)
gnatmake: "mostultimateanswer.adb" compilation error
Can someone give me a hint as to the problem? I am using GNAT 3.15p and
am thinking that I am missing a library or some settings need to be
changed. At the beginning of the program, I do have the lines:
with Ada.Text_IO;
use Ada.Text_Io;
so I believe Text_io should be visible.
However, the tutorial or any reference I can find make no mention of
having to change settings.
I have successfully built "UltimateAnswer" as shown in 1.2.1 with no
problems.
http://www.scism.sbu.ac.uk/law/Section1/chap2/s1c2p1.html
Thanks,
Bill
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie Visibility Problem TEXT_IO.INTEGER_IO
2004-06-02 19:37 Newbie Visibility Problem TEXT_IO.INTEGER_IO bm34mailing<<SPAM-SUCKS>>
@ 2004-06-02 19:48 ` Simon Wright
2004-06-02 21:39 ` bm34mailing<<SPAM-SUCKS>>
2004-06-03 7:16 ` Dmitry A. Kazakov
1 sibling, 1 reply; 6+ messages in thread
From: Simon Wright @ 2004-06-02 19:48 UTC (permalink / raw)
"bm34mailing<<SPAM-SUCKS>>" <"bm34mailing<<SPAM-SUCKS>>"@yahoo.ca> writes:
> with Ada.Text_IO;
> use Ada.Text_Io;
>
> so I believe Text_io should be visible.
Well, no, that use makes the contents of text_io visible, not the
thing itself.
You could try just "use Ada;" or the following .. (I haven't tried it,
too much grief retyping :-)
0007 with ADA.TEXT_IO;
0008 use ADA.TEXT_IO; <<<<<<<<< remove this line
0009
0010 procedure MostUltimateAnswer is
0011
package Text_IO renames Ada.Text_IO;
0012 package IntIo is new TEXT_IO.INTEGER_IO( INTEGER );
0013 use IntIO;
--
Simon Wright 100% Ada, no bugs.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie Visibility Problem TEXT_IO.INTEGER_IO
2004-06-02 19:48 ` Simon Wright
@ 2004-06-02 21:39 ` bm34mailing<<SPAM-SUCKS>>
2004-06-03 8:32 ` Martin Krischik
0 siblings, 1 reply; 6+ messages in thread
From: bm34mailing<<SPAM-SUCKS>> @ 2004-06-02 21:39 UTC (permalink / raw)
Hi Simon:
Thanks for the response. I tried to use your suggestion, but I still
could not build the app. However, I considered your thought on visibility:
<snip>
> Well, no, that use makes the contents of text_io visible, not the
> thing itself.
<snip>
I added the lines:
with Ada;
use Ada;
to make the contents of Ada (i.e Text_IO) visible. This works as I
expected. This does not seem like the best way to resolve the problem,
but I am less than two days into learning about Ada, so I will reserve
final judgment until my understanding of the syntax improves.
Thanks again for the help Simon. I appreciate the quick response.
Bill
"
Simon Wright wrote:
> "bm34mailing<<SPAM-SUCKS>>" <"bm34mailing<<SPAM-SUCKS>>"@yahoo.ca> writes:
>
>
>>with Ada.Text_IO;
>>use Ada.Text_Io;
>>
>>so I believe Text_io should be visible.
>
>
> Well, no, that use makes the contents of text_io visible, not the
> thing itself.
>
> You could try just "use Ada;" or the following .. (I haven't tried it,
> too much grief retyping :-)
>
> 0007 with ADA.TEXT_IO;
> 0008 use ADA.TEXT_IO; <<<<<<<<< remove this line
> 0009
> 0010 procedure MostUltimateAnswer is
> 0011
> package Text_IO renames Ada.Text_IO;
>
> 0012 package IntIo is new TEXT_IO.INTEGER_IO( INTEGER );
> 0013 use IntIO;
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie Visibility Problem TEXT_IO.INTEGER_IO
2004-06-02 19:37 Newbie Visibility Problem TEXT_IO.INTEGER_IO bm34mailing<<SPAM-SUCKS>>
2004-06-02 19:48 ` Simon Wright
@ 2004-06-03 7:16 ` Dmitry A. Kazakov
1 sibling, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2004-06-03 7:16 UTC (permalink / raw)
bm34mailing wrote:
> I am very new to Ada and am having a visibility problem that I am not
> sure how to get around. I am trying to build the "MostUltimateAnswer"
> sample application from the LAW web site (Section 1.2.12).
>
> http://www.scism.sbu.ac.uk/law/Section1/chap2/s1c2p12.html
>
> Can someone give me a hint as to the problem? I am using GNAT 3.15p and
> am thinking that I am missing a library or some settings need to be
> changed. At the beginning of the program, I do have the lines:
>
> with Ada.Text_IO;
> use Ada.Text_Io;
>
> so I believe Text_io should be visible.
It isn't.
I will try to explain it. In the program you have:
package IntIo is new TEXT_IO.INTEGER_IO( INTEGER );
Here Text_IO is not visible, because it is declared in the package Ada. Thus
the variant
(A)
with Ada.Text_IO;
use Ada.Text_IO;
use Ada; -- This makes Text_IO visible!
...
package IntIo is new TEXT_IO.INTEGER_IO( INTEGER );
You can also use the full name of Integer_IO, the following variant:
(B)
with Ada.Text_IO;
...
package IntIo is new ADA.TEXT_IO.INTEGER_IO( INTEGER );
-- The fully qualified name
Though Integer_IO is already visible as other posters noted, so the variant:
(C)
with Ada.Text_IO;
use Ada.Text_IO;
...
package IntIo is new INTEGER_IO( INTEGER );
-- Ada.Text_IO.Integer_IO is visible
And finally, for backward compatibility with Ada 83, there is the package
Text_IO (renamed Ada.Text_IO). Probably that misled the code author, who
mixed both old and new nomenclature. So to complete the picture, in Ada 83
style:
(D)
with Text_IO;
...
package IntIo is new TEXT_IO.INTEGER_IO( INTEGER );
--
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie Visibility Problem TEXT_IO.INTEGER_IO
2004-06-02 21:39 ` bm34mailing<<SPAM-SUCKS>>
@ 2004-06-03 8:32 ` Martin Krischik
2004-06-03 14:47 ` bm34mailing<<SPAM-SUCKS>>
0 siblings, 1 reply; 6+ messages in thread
From: Martin Krischik @ 2004-06-03 8:32 UTC (permalink / raw)
bm34mailing wrote:
> with Ada;
> use Ada;
>
> to make the contents of Ada (i.e Text_IO) visible. This works as I
> expected. This does not seem like the best way to resolve the problem,
> but I am less than two days into learning about Ada, so I will reserve
> final judgment until my understanding of the syntax improves.
For a beginner the best option is not to use "use" at all. OK, you have to
type a lot more but understanding will be better.
Later, when you have the understanding use "use" selective. "with" need to
be placed before package - "use" does not:
with Ada.Text_IO;
package ...
procedure ...
is
use Ada.Text_IO;
begin
end ...;
end ...;
is just as vaild. And the reason why there are two of them.
With Regards
Martin
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie Visibility Problem TEXT_IO.INTEGER_IO
2004-06-03 8:32 ` Martin Krischik
@ 2004-06-03 14:47 ` bm34mailing<<SPAM-SUCKS>>
0 siblings, 0 replies; 6+ messages in thread
From: bm34mailing<<SPAM-SUCKS>> @ 2004-06-03 14:47 UTC (permalink / raw)
Thanks to all for the help with this problem. Martin, Dimtry and Dennis
all made good points that I will remember going forward.
Thanks again to Simon for the original answer.
Bill
Martin Krischik wrote:
> bm34mailing wrote:
>
>
>>with Ada;
>>use Ada;
>>
>>to make the contents of Ada (i.e Text_IO) visible. This works as I
>>expected. This does not seem like the best way to resolve the problem,
>>but I am less than two days into learning about Ada, so I will reserve
>>final judgment until my understanding of the syntax improves.
>
>
> For a beginner the best option is not to use "use" at all. OK, you have to
> type a lot more but understanding will be better.
>
> Later, when you have the understanding use "use" selective. "with" need to
> be placed before package - "use" does not:
>
> with Ada.Text_IO;
>
> package ...
>
> procedure ...
> is
> use Ada.Text_IO;
> begin
> end ...;
>
> end ...;
>
> is just as vaild. And the reason why there are two of them.
>
> With Regards
>
> Martin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-06-03 14:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-02 19:37 Newbie Visibility Problem TEXT_IO.INTEGER_IO bm34mailing<<SPAM-SUCKS>>
2004-06-02 19:48 ` Simon Wright
2004-06-02 21:39 ` bm34mailing<<SPAM-SUCKS>>
2004-06-03 8:32 ` Martin Krischik
2004-06-03 14:47 ` bm34mailing<<SPAM-SUCKS>>
2004-06-03 7:16 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox