comp.lang.ada
 help / color / mirror / Atom feed
From: ada_wizard@toadmail.com
To: comp.lang.ada@ada-france.org
Subject: Re: Problem with visibility of generic package help please
Date: Thu, 11 Dec 2003 10:55:50 -0500
Date: 2003-12-11T10:55:50-05:00	[thread overview]
Message-ID: <mailman.94.1071158156.31149.comp.lang.ada@ada-france.org> (raw)

MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 3.2.1

"Ute" <Ute.Usenet@web.de> writes:

> I'm trying to instantiate a generic package with doesn't become
> visible in the main program. However, the specifiacation of the
> package and the package body do separately compile without errors. I
> am using GNAT.

First, congratulations on learning Ada! it is a great language :)

When I tried to compile your program (with GNAT 3.15p), I got
many error messages. They are telling you what the problem is; you 
just need practice in reading them.

gnatmake -k -O3 -gnatn -gnatwa -I.. generic_sort_demo

Note that I have all warnings turned on (-gnatwa); this is very
helpful.

gcc -c -I./ -O3 -gnatn -gnatwa -I.. -I- ..\generic_sort_demo.adb
generic_sort_demo.adb:5:09: warning: no entities of "float_text_io" are referenced
generic_sort_demo.adb:7:09: warning: no entities of "integer_text_io" are referenced
generic_sort_demo.adb:9:09: warning: no entities of "integer_text_io" are referenced

These are hints that the "put" functions you want to use are not being
used.

generic_sort_demo.adb:17:60: no visible subprogram matches the specification for
"put"

In generic_sort.ads, you have a generic formal procedure parameter:

   with procedure put(X: Elem);

However, the actual declaration of Put in Ada.Integer_Text_IO is:

   procedure Put
     (Item  : in Num;
      Width : in Field := Default_Width;
      Base  : in Number_Base := Default_Base);

The Width and Base parameters have defaults, but that doesn't mean you
can leave them out in generic formals.

generic_sort_demo.adb:17:60: missing specification for "Width" and other formals
with defaults

Which is what this error message says :). GNAT has great error
messages, but you do have to get in the right mind set to read them.

So you need to add the missing parameters in the Put for generic_sort.

Note that Ada.Float_Text_IO has different parameters; you cannot
declare one generic formal procedure Put for both integer and float. 

generic_sort_demo.adb:17:65: no visible subprogram matches the specification for
"get"
generic_sort_demo.adb:17:65: missing specification for "Width"

Same as above.

generic_sort_demo.adb:19:08: "int_arr_sort" is undefined
generic_sort_demo.adb:19:08: possible misspelling of "int_arrr_sort"

This is clear, I hope; you typed 3 r's by mistake. GPS and Emacs will
automatically correct this sort of error, at a single keystroke.

generic_sort_demo.adb:21:09: "ArrTyp" is not visible
generic_sort_demo.adb:21:09: non-visible declaration at generic_sort.ads:15
generic_sort_demo.adb:27:04: "get_array" is not visible
generic_sort_demo.adb:27:04: non-visible declaration at generic_sort.ads:25
generic_sort_demo.adb:33:04: "put_array" is not visible (more references follow)
generic_sort_demo.adb:33:04: non-visible declaration at generic_sort.ads:23
generic_sort_demo.adb:37:04: "sort" is not visible
generic_sort_demo.adb:37:04: non-visible declaration at generic_sort.ads:21

These can be somewhat confusing. You are trying to use the subprograms
defined by your generic; the problem is that the generic instantiation
failed, so they are not visible. GNAT tries to be helpful and find
other places where the same names are visible. In this case, it
guessed wrong.


I suggest you separate the "put" functionality from the "sort"
functionality; put them in separate packages. That will help a lot.

You should consider using SAL.Gen_Array_Text_IO
(http://www.toadmail.com/~ada_wizard/) for the "put" part; it "just
works", and supports integer and float arrays "out of the box", so you
can just focus on the "sort" part. Even if this is homework, I would
not call it cheating; having to do complex Text_IO in order to do the
"real work" is just annoying. So take advantage of what's out there.

-- 
-- Stephe

___________________________________________________________
This mail sent using ToadMail -- Web based e-mail @ ToadNet



             reply	other threads:[~2003-12-11 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-11 15:55 ada_wizard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-11 14:37 Problem with visibility of generic package help please amado.alves
2003-12-11 14:03 Ute
2003-12-11 15:15 ` Georg Bauhaus
2003-12-11 18:07 ` Jeffrey Carter
2003-12-16 21:00 ` Martin Krischik
replies disabled

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