And if this is really an declaration, the compiler would not have granted that you cannot declare a function inside a function.
Of course not. Because it can declare a function with a function.
This is called the most unpleasant analysis , and it is well documented. In fact, it would be a mistake on behalf of the compiler to consider
List x();
as a variable declaration.
But is it really wrong to use the second option?
If you want a variable, then yes. If you want to declare a function ... kinda yes. You can, but usually you do it outside the scope.
source share