* Instantiating generics @ 2003-12-09 10:02 Albert 2003-12-09 12:10 ` David C. Hoos 0 siblings, 1 reply; 4+ messages in thread From: Albert @ 2003-12-09 10:02 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Instantiating generics 2003-12-09 10:02 Instantiating generics Albert @ 2003-12-09 12:10 ` David C. Hoos 2003-12-10 10:36 ` Albert 0 siblings, 1 reply; 4+ messages in thread From: David C. Hoos @ 2003-12-09 12:10 UTC (permalink / raw) 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? "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 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Instantiating generics 2003-12-09 12:10 ` David C. Hoos @ 2003-12-10 10:36 ` Albert 2003-12-10 12:21 ` David C. Hoos, Sr. 0 siblings, 1 reply; 4+ messages in thread From: Albert @ 2003-12-10 10:36 UTC (permalink / raw) 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 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 >> >> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Instantiating generics 2003-12-10 10:36 ` Albert @ 2003-12-10 12:21 ` David C. Hoos, Sr. 0 siblings, 0 replies; 4+ messages in thread From: David C. Hoos, Sr. @ 2003-12-10 12:21 UTC (permalink / raw) To: Albert; +Cc: comp.lang.ada ----- 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 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-12-10 12:21 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox