digitalmars.D - interface: static functions
- Markus Kranz (10/10) Apr 25 2006 Is there a reason, one can define static functions in interfaces,
- Alberto Simon (7/18) Apr 25 2006 It is confusing since an interface by definition is a contract (I'm not ...
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (23/39) Apr 25 2006 I can confirm it. It has been that way for a long time. D interfaces
Is there a reason, one can define static functions in interfaces, but 'implementing' classes don't really have to implement them? interface A { static void doIt(); } class B : A { } is valid dmd 0.154 (linux) code. Regards, Markus
Apr 25 2006
It is confusing since an interface by definition is a contract (I'm not that familiar with D but am with interfaces) would say it is a bug, but I can't confirm it. Regards, Alberto Simon "Markus Kranz" <Markus_member pathlink.com> escribió en el mensaje news:e2lqru$jgq$1 digitaldaemon.com...Is there a reason, one can define static functions in interfaces, but 'implementing' classes don't really have to implement them? interface A { static void doIt(); } class B : A { } is valid dmd 0.154 (linux) code. Regards, Markus
Apr 25 2006
"Markus Kranz" <Markus_member pathlink.com> escribió en el mensaje news:e2lqru$jgq$1 digitaldaemon.com...Alberto Simon wrote:Is there a reason, one can define static functions in interfaces, but 'implementing' classes don't really have to implement them? interface A { static void doIt(); } class B : A { } is valid dmd 0.154 (linux) code.It is confusing since an interface by definition is a contract (I'm not that familiar with D but am with interfaces) would say it is a bug, but I can't confirm it.I can confirm it. It has been that way for a long time. D interfaces should be wholly reimplemented. There are some serious limitations and problems now. One other funny thing are protection attributes: SuperClass: Identifier Protection Identifier InterfaceClass: Identifier Protection Identifier Protection: private package public export http://www.digitalmars.com/d/class.html I think they are legacy syntax from C++. There is no point in limiting the visibility of interface members. AFAIK they aren't even implemented at the moment, but DMD successfully accepts them. Implementing these would probably break the interface covariance stuff also. -- Jari-Matti
Apr 25 2006