Denis Koroskin wrote:
Unfortunately, you still have to special-case void type in a lot of cases. Here are just 2 examples:

And that's why there were ideas to allow declaring void variables.
IMHO these void variables should allow all common operations on normal variables (assignment, passing as function parameter, taking address, dereferencing, void.init), and the compilation of those should simply result in no code.

RetType doSomething(Args, RetType)(Args args, RetType retType)
{
    RetType result = callSomeDelegate(args);    // doesn't work for 'void'
    addLogEntry("bla-bla-bla");
    return result;
}

class Test(T)
{
    T foo(T t) { ... }
    T bar() { ... }

    T test()
    {
        return bar(foo()); // works for all types but 'void'
    }
}

Reply via email to