How about a handy way of wrapping all function parameters?

Andrej Mitrovic none at none.none
Tue Apr 5 20:23:01 PDT 2011


E.g. this code:

class Foo
{
    int wndProc(uint msg, int wParam, int lParam) { return 0; }
}

class Bar : Foo
{
    override int wndProc(uint msg, int wParam, int lParam)
    {
        switch(msg)
        {
            case 1:
                return 1;
            
            default:
                return super.wndProc(msg, wParam, lParam);
        }
    }
}

Sometimes you just want to pass all the arguments of a function call to the equivalent overriden function in a base class. But you still have to list all the parameters by hand, which means a lot of needless copy-pasting is needed.

What would be fantastic here is to be able to use static introspection and just pass on the arguments via a simple intrinsic call, e.g.:

            default:
                return forward!super;  // forward all arguments to super's
                                               // method with the same name

Do we have something like this already? If not I'd write an enhancement request.


More information about the Digitalmars-d-learn mailing list