Why can't a method be virtual AND static at the same time?

Martin Cejp minexew at gmail.com
Wed Jan 29 06:32:33 PST 2014


On Wednesday, 29 January 2014 at 14:29:24 UTC, Tobias Pankrath 
wrote:
>> Such definition of ConsoleLogger fails to compile. I don't see
>> any drawbacks to allowing this though, except the compiler 
>> would
>> probably have to generate 2 methods internally.
>> The way it is now, you have to either define each method twice 
>> or
>> always create an instance.
>> Or am I missing an obvious solution?
>
> Instead of defining it twice, you could alias the base version.

What do you mean? The methods have different signatures (static x 
virtual)

By the way, what I want to do is have a class LocalFileSystem 
that can both
be passed as a FileSystem implementation and used directly,
without instantiation (LocalFileSystem.openFile)


More information about the Digitalmars-d mailing list