Type D inference of nested functions

Does anyone know if subj will be implemented? At least for them an autosave class? Thank!

+3
source share
1 answer

There are various problems with auto functions in general, so it may well be that you cannot do

void main()
{
    auto bar() { return "hello world"; }

    writeln(bar());
}

due to a mistake with the car, and not due to the fact that it was designed. I'm not sure what these exact plans are, although I would have thought that you should use auto as the return type of a nested function. In this case, there is a request for improvement on it .

However, regardless of whether auto works with nested functions, you can declare a delegate in the same way:

void main()
{
    auto bar = () { return "hello world"; };

    writeln(bar());
}

, , , , .

+4

Source: https://habr.com/ru/post/1775581/


All Articles