what is a usage pattern for "static" in an interface?

dennis luehring dl.soluz at gmx.net
Fri Feb 3 05:03:22 PST 2012


Am 03.02.2012 13:38, schrieb Jacob Carlborg:
> On 2012-02-03 13:24, dennis luehring wrote:
>>  Am 03.02.2012 13:10, schrieb dennis luehring:
>>>  Am 03.02.2012 13:02, schrieb Jonathan M Davis:
>>>>  C++ doesn't have interfaces, and C# and Java don't allow function
>>>>  implementations of any kind on interfaces. The same is not true for D.
>>>
>>>  but as you can see in my example - my static function isn't implemented
>>>  in the interface scope
>>>
>>>  interface test
>>>  {
>>>  static void blub();<----
>>>  }
>>>
>>>  there is no example of an not implemented static in a interface
>>>
>>>
>>
>>  i think should file an bug report for both
>
> The implementation could come from a different object file. But you
> should get a linker error if it doesn't.
>

another problem i've found

interface itest
{
   static void blub(){};
}

class A: itest
{
   void blub(){};
}

class A overrides (silently) the static blub from the interface with an 
normal method

itest it = new A();

A.blub(); // error - not a static
it.blub(); // ok

or

interface itest
{
   static void blub(){}
}

class A: itest
{
   static void blub(){}
}

class A just override blub()



More information about the Digitalmars-d mailing list