interface: static functions

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Tue Apr 25 13:41:04 PDT 2006


> "Markus Kranz" <Markus_member at pathlink.com> escribió en el mensaje 
> news:e2lqru$jgq$1 at 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.

Alberto Simon wrote:
> 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



More information about the Digitalmars-d mailing list