comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
To: "Albert" <weeper_MATEMLSPAM_@menta.net>
Cc: comp.lang.ada@ada-france.org
Subject: Re: Instantiating generics
Date: Wed, 10 Dec 2003 06:21:17 -0600
Date: 2003-12-10T06:21:17-06:00	[thread overview]
Message-ID: <mailman.67.1071058904.31149.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: pan.2003.12.10.10.36.56.839273@menta.net


----- Original Message ----- 
From: "Albert" <weeper_MATEMLSPAM_@menta.net>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada-france.org>
Sent: December 10, 2003 4:36 AM
Subject: Re: Instantiating generics


> On Tue, 09 Dec 2003 06:10:20 -0600, David C. Hoos wrote:
>
> > We would be more able to help you if you told us what the
> > problem is -- e.g., what error message did you get from the
> > compiler?
>
> Yes, of course, i'm sorry about that....
>
> albert@itaka:~/Ada/practica$ gnatmake demostration.adb
> gnatgcc -c demostration.adb
> demostration.adb:8:18: warning: not dispatching  (must be defined in a package spec)
> demostration.adb:13:09: missing actual for instantiation of "Is_Valid"
> demostration.adb:13:09: instantiation abandoned
> gnatmake: "demostration.adb" compilation error

As is almost always the case with gnat, the messages from the compiler
are very precise, and tell you exactly what the problem is.
Here, it is telling you that the instantiation of the gheneric package
Queue_Manager_1 is missing the actual parameter for the formal
parameter Is_Valid, required by Queue_Manager_1.

There are two ways to correct this, viz.:
  1.  You can supply the parameter explicitly like this:
     package QMP is new Queue_Manager_1
         (Element => O_Positive;
          Is_Valid => is_Valid);

  2.  You can change the definition of the formal parameter
      Is_Valid in Queue_Manager_1, like this:
with function Is_Valid(Data : Element) return Boolean is <>; -- 6
instead of
with function Is_Valid(Data : Element) return Boolean; -- 6

The addition of the "is <>" to the formal paramter declaration
tells the compiler to supply the required actual parameter
if one with the same name and profile is visible at the
point of instantiation.

I warn you now, that when you make one or the other of these
changes you will encounter some new problems, but it is better
for your learning experience to see them for yourself, and
see whether you can fix them yourself, based on what the
compiler tells you.

If you cannot solve them, let us know, and we'll try to help.


>
> Albert
>
> >
> > "Albert" <weeper_MATEMLSPAM_@menta.net> wrote in message
> > news:pan.2003.12.09.10.02.31.801470@menta.net...
> >> I'm trying to instantiate the Queue_Manager_1 example from 12.3
> >> Ada Distillier, the problem is the function Is_Valid.
> >>
> >> with Queue_Manager_1;
> >>
> >> procedure Demostration is
> >> type O_Positive is tagged
> >> record
> >> Val:Positive;
> >> end record;
> >> function Is_Valid(Data:O_Positive) return Boolean is
> >> begin
> >> return True;
> >> end Is_Valid;
> >> package QMP is new Queue_Manager_1(Element=>O_Positive);
> >> begin
> >> null;
> >> end Demostration;
> >>
> >>
> >> Can anyone help me�.
> >> thanks
> >>
> >> Albert
> >>
> >>
> >> _______________________________________________
> >> comp.lang.ada mailing list
> >> comp.lang.ada@ada-france.org
> >> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
> >>
> >>
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
>
>





      reply	other threads:[~2003-12-10 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-09 10:02 Instantiating generics Albert
2003-12-09 12:10 ` David C. Hoos
2003-12-10 10:36   ` Albert
2003-12-10 12:21     ` David C. Hoos, Sr. [this message]
replies disabled

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