Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 9 23:34:19 PDT 2014


On Friday, 10 October 2014 at 02:38:42 UTC, Walter Bright wrote:
> For functions, const-as-storage-class applies to the function 
> symbol. And if it is misused, the compiler will very likely 
> complain about a mismatched type.
> Breaking this adds a special case inconsistency, besides 
> breaking existing code.
>

Come on that is the same bogus reason every time. const here do 
not apply to the function but to its hidden, implicit parameter. 
And that is actually a problem.

const void delegate() dg; // dg should be const, and there is no 
way to qualify the implicit parameter.

You obviously can't pretend you don't know this as:
const int foo() {}

Gives you an error because you have no this pointer to make 
const. So let's not pretend that this const actually qualify the 
function when everybody knows it doesn't.


More information about the Digitalmars-d mailing list