www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - disable usage and design

This is something I have already asked about in D.learn and the IRC channel,
with no luck.
This D2 code used  disable:

import std.c.stdio: puts;
class A {
    void foo() { puts("A.foo()"); }
class B : A {
    // disable override void foo(); // Linker error  
     disable override void foo() { puts("B.foo()"); }; // OK
class C : B {
    override void foo() { puts("C.foo()"); };
void main() {
    A b = new B;
    b.foo(); // Output: B.foo()
    B b2 = cast(B)b;
    // Compile-time Output: Error: function test.B.foo is not callable because
it is annotated with  disable
    C c = new C;
    c.foo(); // Output: C.foo()

Is this how  disable is supposed to work (or is it only partially implemented)?

Isn't   disable override void foo();  more meaningful than giving a body to a
disabled function?

As you can see the first call to foo prints "B.foo()", that is calls the
disable method. Isn't a runtime exception better in this case?

Is overriding a disabled function meaningful?

Thank you,
Apr 27 2010