Unnamed parameter with default value

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 17 08:19:46 PDT 2014


On Tue, 17 Jun 2014 11:15:43 -0400, Luís Marques <luis at luismarques.eu>  
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?

Of course this should be accepted. Omitting the name has nothing to do  
with the API, but has to do with the fact that the implementation doesn't  
use it. An implementation may be constrained by a base class or by some  
duck-type requirement even though it doesn't use the parameter.

-Steve


More information about the Digitalmars-d mailing list