what is a usage pattern for "static" in an interface?
Martin Nowak
dawg at dawgfoto.de
Fri Feb 3 17:54:02 PST 2012
On Fri, 03 Feb 2012 08:30:31 +0100, dennis luehring <dl.soluz at gmx.net>
wrote:
> like:
>
> public interface test
> {
> public static void blub();
> }
>
> static class test_static: test
> {
> private static void blub()
> {
> int i = 10;
> }
> }
>
> int main()
> {
> test_static.blub();
>
> return 0;
> }
>
> any idea why static could makes sense in an interface? any example?
>
> another thing:
>
> why can i public "blub" in the interface and private it in the class?
It's a bug of the compiler to ignore unapplicaple attributes.
http://d.puremagic.com/issues/show_bug.cgi?id=3934
http://d.puremagic.com/issues/show_bug.cgi?id=3118
> http://blog.xebia.fr/2011/10/05/les->methodes-virtuelles-dextension-dans-java-8/
> http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf
Allowing default implementations in interfaces is a great to be able to
extend
interfaces without breaking dependent code and also to simplify class
implementation.
If override were mandatory in implementation classes we could easily allow
implementations
in interfaces.
More information about the Digitalmars-d
mailing list