* formal package question
@ 2011-02-14 2:46 ytomino
2011-02-14 6:51 ` anon
2011-02-14 9:59 ` Georg Bauhaus
0 siblings, 2 replies; 9+ messages in thread
From: ytomino @ 2011-02-14 2:46 UTC (permalink / raw)
Hello,
Please look this code:
--------
package formalpkg is
generic
type T is private;
with procedure P (X : T) is <>;
package F is
end F;
generic
with package FA is new F (others => <>);
package B is
end B;
procedure P1 (X : Character) is null;
package F1 is new F (Character, P1); -- use P => P1
package B1 is new B (F1); -- Error !!
procedure P (X : Character) is null;
package F2 is new F (Character); -- P => P
package B2 is new B (F2); -- OK
end formalpkg;
--------
% gnatmake formalpkg.ads
gcc -c formalpkg.ads
formalpkg.ads:17:25: actual for "P" in actual instance does not match
formal
gnatmake: "formalpkg.ads" compilation error
--------
B1 was compile error, but B2 is ok. Why?
Where is wrong in my code?
I want to use instances of generic package with some different
subprograms like B1...
(I use gcc-4.5.1)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-14 2:46 formal package question ytomino
@ 2011-02-14 6:51 ` anon
2011-02-15 0:08 ` ytomino
2011-02-14 9:59 ` Georg Bauhaus
1 sibling, 1 reply; 9+ messages in thread
From: anon @ 2011-02-14 6:51 UTC (permalink / raw)
Typo:
package F2 is new F (Character, P); -- P => P
In <a1ce6c12-d389-4685-95b2-68159efefadc@s11g2000prs.googlegroups.com>, ytomino <aghia05@gmail.com> writes:
>Hello,
>Please look this code:
>
>--------
>package formalpkg is
>
> generic
> type T is private;
> with procedure P (X : T) is <>;
> package F is
> end F;
>
> generic
> with package FA is new F (others => <>);
> package B is
> end B;
>
> procedure P1 (X : Character) is null;
> package F1 is new F (Character, P1); -- use P => P1
>
> package B1 is new B (F1); -- Error !!
>
> procedure P (X : Character) is null;
> package F2 is new F (Character); -- P => P
>
> package B2 is new B (F2); -- OK
>
>end formalpkg;
>--------
>% gnatmake formalpkg.ads
>gcc -c formalpkg.ads
>formalpkg.ads:17:25: actual for "P" in actual instance does not match
>formal
>gnatmake: "formalpkg.ads" compilation error
>--------
>
>B1 was compile error, but B2 is ok. Why?
>Where is wrong in my code?
>I want to use instances of generic package with some different
>subprograms like B1...
>
>(I use gcc-4.5.1)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-14 2:46 formal package question ytomino
2011-02-14 6:51 ` anon
@ 2011-02-14 9:59 ` Georg Bauhaus
2011-02-14 15:38 ` Adam Beneschan
2011-02-15 0:31 ` ytomino
1 sibling, 2 replies; 9+ messages in thread
From: Georg Bauhaus @ 2011-02-14 9:59 UTC (permalink / raw)
On 14.02.11 03:46, ytomino wrote:
> Hello,
> Please look this code:
>
> --------
> package formalpkg is
>
> generic
> type T is private;
> with procedure P (X : T) is <>;
> package F is
> end F;
>
> generic
> with package FA is new F (others => <>);
> package B is
> end B;
>
> procedure P1 (X : Character) is null;
> package F1 is new F (Character, P1); -- use P => P1
>
> package B1 is new B (F1); -- Error !!
>
> procedure P (X : Character) is null;
> package F2 is new F (Character); -- P => P
>
> package B2 is new B (F2); -- OK
>
> end formalpkg;
> --------
> % gnatmake formalpkg.ads
> gcc -c formalpkg.ads
> formalpkg.ads:17:25: actual for "P" in actual instance does not match
> formal
> gnatmake: "formalpkg.ads" compilation error
> --------
>
> B1 was compile error, but B2 is ok. Why?
I get an error for B2, probably using a different GNAT.
Not really an answer, but can you leave out the "others"
in ([others =>] <>) ?
package Formalpkg is
generic
type T is private;
with procedure P (X : T) is <>;
package F is
end F;
generic
with package FA is new F (<>);
package B is
end B;
procedure P1 (X : Character) is null;
package F1 is new F (Character, P1);
package B1 is new B (F1);
procedure P (X : Character) is null;
package F2 is new F (Character);
package B2 is new B (F2);
end Formalpkg;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-14 9:59 ` Georg Bauhaus
@ 2011-02-14 15:38 ` Adam Beneschan
2011-02-15 0:31 ` ytomino
1 sibling, 0 replies; 9+ messages in thread
From: Adam Beneschan @ 2011-02-14 15:38 UTC (permalink / raw)
On Feb 14, 1:59 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> On 14.02.11 03:46, ytomino wrote:
>
>
>
>
>
> > Hello,
> > Please look this code:
>
> > --------
> > package formalpkg is
>
> > generic
> > type T is private;
> > with procedure P (X : T) is <>;
> > package F is
> > end F;
>
> > generic
> > with package FA is new F (others => <>);
> > package B is
> > end B;
>
> > procedure P1 (X : Character) is null;
> > package F1 is new F (Character, P1); -- use P => P1
>
> > package B1 is new B (F1); -- Error !!
>
> > procedure P (X : Character) is null;
> > package F2 is new F (Character); -- P => P
>
> > package B2 is new B (F2); -- OK
>
> > end formalpkg;
> > --------
> > % gnatmake formalpkg.ads
> > gcc -c formalpkg.ads
> > formalpkg.ads:17:25: actual for "P" in actual instance does not match
> > formal
> > gnatmake: "formalpkg.ads" compilation error
> > --------
>
> > B1 was compile error, but B2 is ok. Why?
>
> I get an error for B2, probably using a different GNAT.
> Not really an answer, but can you leave out the "others"
> in ([others =>] <>) ?
Yes, it compiles for me if I say F(<>) but gets an error with F(others
=> <>). There should be no difference between the two syntaxes, so
this is an error in the compiler.
-- Adam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-14 9:59 ` Georg Bauhaus
2011-02-14 15:38 ` Adam Beneschan
@ 2011-02-15 0:31 ` ytomino
2011-02-15 8:17 ` Ludovic Brenta
1 sibling, 1 reply; 9+ messages in thread
From: ytomino @ 2011-02-15 0:31 UTC (permalink / raw)
I tried to remove "others =>", and got same result that it compiled
correctly.
umm...
This behavior of compiler limits using formal parameter...
I want to write partial parameters and use defaults for remaining
parameters.
But gcc(GNAT) can compile the example in
http://www.adaic.org/resources/add_content/standards/05rm/html/RM-12-7.html
I deduce, this behavior is applied only to generic package having
formal package having formal subprograms ???
Thank you.
On Feb 14, 6:59 pm, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
>
> I get an error for B2, probably using a different GNAT.
> Not really an answer, but can you leave out the "others"
> in ([others =>] <>) ?
>
> package Formalpkg is
>
> generic
> type T is private;
> with procedure P (X : T) is <>;
> package F is
> end F;
>
> generic
> with package FA is new F (<>);
> package B is
> end B;
>
> procedure P1 (X : Character) is null;
> package F1 is new F (Character, P1);
>
> package B1 is new B (F1);
>
> procedure P (X : Character) is null;
> package F2 is new F (Character);
>
> package B2 is new B (F2);
>
> end Formalpkg;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-15 0:31 ` ytomino
@ 2011-02-15 8:17 ` Ludovic Brenta
2011-02-17 0:58 ` ytomino
0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Brenta @ 2011-02-15 8:17 UTC (permalink / raw)
ytomino wrote on comp.lang.ada:
> I tried to remove "others =>", and got same result that it compiled
> correctly.
> umm...
> This behavior of compiler limits using formal parameter...
> I want to write partial parameters and use defaults for remaining
> parameters.
>
> But gcc(GNAT) can compile the example inhttp://www.adaic.org/resources/add_content/standards/05rm/html/RM-12-...
> I deduce, this behavior is applied only to generic package having
> formal package having formal subprograms ???
>
> Thank you.
I reported this bug as http://gcc.gnu.org/PR47748 for you.
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-15 8:17 ` Ludovic Brenta
@ 2011-02-17 0:58 ` ytomino
2011-02-17 7:05 ` Ludovic Brenta
0 siblings, 1 reply; 9+ messages in thread
From: ytomino @ 2011-02-17 0:58 UTC (permalink / raw)
> I reported this bug ashttp://gcc.gnu.org/PR47748for you.
Thank you very much!
> with package FA is new F (others => <>); -- line 17
An added comment "-- line 17" is misplaced. The real line 17 is
> package B1 is new B (F1); -- Error !!
On Feb 15, 5:17 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>
> I reported this bug ashttp://gcc.gnu.org/PR47748for you.
>
> --
> Ludovic Brenta.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: formal package question
2011-02-17 0:58 ` ytomino
@ 2011-02-17 7:05 ` Ludovic Brenta
0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Brenta @ 2011-02-17 7:05 UTC (permalink / raw)
ytomino writes on comp.lang.ada:
>> I reported this bug as http://gcc.gnu.org/PR47748 for you.
> Thank you very much!
>
>> with package FA is new F (others => <>); -- line 17
> An added comment "-- line 17" is misplaced. The real line 17 is
>> package B1 is new B (F1); -- Error !!
I realized that after the fact ut it doesn't matter because, in the
comments, I say: "On line 17, replacing "others => <>" with just "<>"
makes the package compile cleanly.". I might as well have said "on line
A".
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-02-17 7:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-14 2:46 formal package question ytomino
2011-02-14 6:51 ` anon
2011-02-15 0:08 ` ytomino
2011-02-14 9:59 ` Georg Bauhaus
2011-02-14 15:38 ` Adam Beneschan
2011-02-15 0:31 ` ytomino
2011-02-15 8:17 ` Ludovic Brenta
2011-02-17 0:58 ` ytomino
2011-02-17 7:05 ` Ludovic Brenta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox