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,104df2b9b7a2f689 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Interfaces Date: 16 May 2005 14:59:45 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <8764xj9wzf.fsf@deneb.enyo.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1116269985 23879 192.74.137.71 (16 May 2005 18:59:45 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 16 May 2005 18:59:45 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:11043 Date: 2005-05-16T14:59:45-04:00 List-Id: Florian Weimer writes: > Suppose there are two interface types, J1 and J2, and the following > dispatching subprogramms: > > procedure Foo (Obj : J1); > procedure Foo (Obj : J2; > > T implements both J1 and J2, and provides a body for > > procedure Foo (Obj : T); > > As far as I understand the Ada 200x spec, this subprogram declaration > overrides both versions of Foo, such that > > Foo ((J1 (T_Obj)); > Foo ((J2 (T_Obj)); > > invoke the same subprogram. Is this correct? I believe so. > I don't think this is a desirable approach because it makes interfaces > a strictly non-modular concept, and might force library designers to > add unique prefixes to interface subprogram names. Perhaps. If you override a procedure, you need to obey the comments on the original declaration, which specify what it is supposed to (or allowed to) do. If you override two things at once, you have to obey two (possibly different) contracts. If you find you can't do that, you've got a name clash. The usual way to fix it is to change one of the names. If you choose descriptive names (not "Foo" ;-)) name clashes will be rare. If those two Foo's came from two separate third-partly libraries, then it can be painful or impossible to change the name. Various workarounds are possible. Look at Eiffel for one possible solution to this problem. It's pretty complicated, and could cause some confusion (for example, Bar overrides Foo, because somewhere in the chain of derivations somebody renamed Foo to Bar). I was at an ARG meeting a while ago where this name-conflict problem was discussed. At first, I advocated solving it (perhaps with an Eiffel-like solution, perhaps some other solution). One response was that we should solve this problem if and when Ada becomes so popular that there are zillions of libraries causing name conflicts. ;-) But the main argument against solving this problem is that it would introduce a huge amount of complexity to solve a fairly rare problem. I was pretty-much convinced by that. Ada's interfaces were modeled primarily after Java's interfaces, by the way. - Bob