On Tuesday, 17 June 2014 at 15:15:44 UTC, Luís Marques wrote:
Is there any particular reason why this is accepted? (I
introduced it by mistake):
void foo(int = 3) {}
I guess it could be useful to ensure binary compatibility when
you expect to add the parameter later?
Actually there is nothing strange because current implementation
technically does not remove variable names, it generates implicit
ones. This compiles:
void foo(int = 0)
{
_param_0 = 1;
}
and is equivalent to
void foo(int _param_0 = 0)
{
_param_0 = 1;
}
It is not a wise design decision which is aimed to support some
case, it is just technical consequence of implementation.
And I don't think that it has anything to do with binary
compatibility, because both parameter names and default arguments
exists only in compile time.