comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interfaces
Date: Tue, 17 May 2005 18:21:12 -0500
Date: 2005-05-17T18:21:12-05:00	[thread overview]
Message-ID: <CrydncVYZ7xS5hffRVn-pg@megapath.net> (raw)
In-Reply-To: 87zmutsenr.fsf@deneb.enyo.de

"Florian Weimer" <fw@deneb.enyo.de> wrote in message
news:87zmutsenr.fsf@deneb.enyo.de...
...
> > Anyway, I thought you were worried about the case where T implements J1
> > and J2, both of which have type-conformant Foo's.  And you override them
> > separately.  Then it's clear which one you dispatch to from J1'Class
> > and J2'Class.  But if you have an object X of type T, which overriding
> > does Foo(X) call?
>
> My knee-jerk reaction is: require a type conversion in all cases.
> Probably unacceptable if you want to compete with Java. 8->

Interfaces are a weird beast, rather different from the other sort of types
in Ada. They really have a fairly global scope, and even more interesting,
the number of times or the place that you inherit them doesn't have any
effect on their semantics.

Because of that, they are only usable when there is no chance of needing
more than one implementation. (For instance, sorting would be a bad use for
an interface, because you may want to sort the same type in more than one
way. But you can't do that with interfaces.)

Similarly, the operations need to have well-defined semantics. And if
multiple interfaces have the same operation; it is the *same* operation.
Essentially, all of the operations of all of the interfaces in a program are
a global grouping -- *you* have to keep the names separate.

Because of these issues, I find interfaces to be a concept with very limited
utility. They're mostly useful for things that otherwise wouldn't have any
way to share code (such as tasks or protected objects with different
implementations). I just wasn't going to win the fight to keep them out of
Ada 2006.

(Of course, in 5 years someone will stick this note in my face when I'm
advocating some sort of interface programming. I'm prepared. :-)

                                          Randy Brukardt.






  reply	other threads:[~2005-05-17 23:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-16 12:27 Interfaces Florian Weimer
2005-05-16 16:13 ` Interfaces Georg Bauhaus
2005-05-16 16:12   ` Interfaces Florian Weimer
2005-05-16 18:59 ` Interfaces Robert A Duff
2005-05-16 19:27   ` Interfaces Florian Weimer
2005-05-16 20:09     ` Interfaces Robert A Duff
2005-05-16 20:44       ` Interfaces Florian Weimer
2005-05-17  6:14     ` Interfaces Vinzent 'Gadget' Hoefler
2005-05-17 10:53       ` Interfaces Florian Weimer
2005-05-17 13:34         ` Interfaces Vinzent 'Gadget' Hoefler
     [not found]         ` <4289f382$0$10805$afc38c87@>
2005-05-17 16:51           ` Interfaces Pascal Obry
     [not found]             ` <428a2832$0$10805$afc38c87@>
2005-05-17 18:15               ` Interfaces Pascal Obry
2005-05-17 21:11                 ` Interfaces Florian Weimer
2005-05-18 10:36                   ` Interfaces Georg Bauhaus
2005-05-17  7:36     ` Interfaces Dmitry A. Kazakov
2005-05-17  9:06       ` Interfaces Florian Weimer
2005-05-17 10:19         ` Interfaces Dmitry A. Kazakov
2005-05-17 10:57           ` Interfaces Florian Weimer
2005-05-17 11:13             ` Interfaces Dmitry A. Kazakov
2005-05-17 15:35               ` Interfaces Robert A Duff
2005-05-17 21:53                 ` Interfaces Florian Weimer
2005-05-17 23:21                   ` Randy Brukardt [this message]
2005-05-17 23:44                     ` Interfaces Marius Amado Alves
2005-05-18  7:53                     ` Interfaces Dmitry A. Kazakov
2005-05-18 16:57 ` Interfaces adam
2005-05-20  5:31 ` Interfaces Matthew Heaney
replies disabled

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