From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4894bc8fcf637af8 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.cs.univ-paris8.fr!u-psud.fr!not-for-mail From: Philippe Tarroux Newsgroups: comp.lang.ada Subject: Re: Interfaces and private types Date: Tue, 29 Jan 2008 10:35:40 +0100 Organization: University Paris-Sud, France. Message-ID: References: NNTP-Posting-Host: osiris.limsi.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news2.u-psud.fr 1201599244 19438 129.175.157.197 (29 Jan 2008 09:34:04 GMT) X-Complaints-To: newsmaster@u-psud.fr NNTP-Posting-Date: Tue, 29 Jan 2008 09:34:04 +0000 (UTC) User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:19646 Date: 2008-01-29T10:35:40+01:00 List-Id: Randy Brukardt wrote: > Specifically, it violates 7.3(7.3/2): "the partial view shall be a > descendant of an interface type (see 3.9.4) if and only if the full type is > a descendant of the interface type." > > As written, this is illegal because type T does not have the interface > Int. As it is written the compiler i use doesn't mention any error and i interpreted this construct as legal because : 1/ the interface is synchronized thus allowing to derive concurrent or non concurrent types 2/ The partial view is a descendant of the interface type 3/ The full view precises that the partial view correspond to a concurrent type but hides this detail to the user Writing, as you propose task type T is new Int with private; tells the user that T is a concurrent type, what precisely i wanted to avoid. > Assuming that this is just a mistake in your interface and you meant > > task type T is new Int with > > then your program is legal, and you should complain your your compiler > vendor about the bug. In no case should there be an error on the declaration > of the object, so that makes it pretty clear that there is a compiler bug. > > You could work around the bug with something like: > > package Test_Interfaces is > > type Int is synchronized interface; > procedure Init (I : in out Int) is abstract; > > type T is new Int with private; > overriding procedure Init (I : in out T); > > private > > task type T is new Int with > entry Init; > end T; > end Test_Interfaces; > > and then have > procedure Init (I : in out T) is > begin > I.Init; > end Init; > in the body. (But note that this runs into a known bug in the Ada standard, > so it isn't clear that the code will work right.) > But the overriding procedure Init needs to be redefined both as an entry of T and as a procedure. I assume that when i will be trying to call O.Init with O a type T task there will be a mistake due to the double definition. But, anyway, thanks a lot for the comments. I am waiting for comments from the guys who are in charge of the gnat compiler. Philippe Tarroux