June 30, 2004 Static methods in interfaces? | ||||
---|---|---|---|---|
| ||||
interface Foo { static Foo opCall() { return null; } } Compiling the above code gives "function opCall function body is not abstract in interface Foo". Personally, I'm in favour of letting interfaces have unrestricted static members, in this case to allow all implementations of the type to be hidden. Whether or not that's allowed, this error message is wrong. If interfaces can have static methods, then this should compile fine. If they can't the error should say so. Thoughts? Sam |
June 30, 2004 Re: Static methods in interfaces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sam McCall | >Personally, I'm in favour of letting interfaces have unrestricted static members, in this case to allow all implementations of the type to be hidden. I disagree, I dont think interfaces should have any method bodies, but I do agree an error let u know that :) Charlie In article <cbt22d$f7i$1@digitaldaemon.com>, Sam McCall says... > >interface Foo { > static Foo opCall() { > return null; > } >} > >Compiling the above code gives "function opCall function body is not >abstract in interface Foo". >Personally, I'm in favour of letting interfaces have unrestricted static >members, in this case to allow all implementations of the type to be >hidden. Whether or not that's allowed, this error message is wrong. >If interfaces can have static methods, then this should compile fine. >If they can't the error should say so. >Thoughts? > >Sam |
Copyright © 1999-2021 by the D Language Foundation