digitalmars.D - Unnamed parameter with default value
- =?UTF-8?B?Ikx1w61z?= Marques" (5/5) Jun 17 2014 Is there any particular reason why this is accepted? (I
-
Steven Schveighoffer
(10/15)
Jun 17 2014
On Tue, 17 Jun 2014 11:15:43 -0400, Lu=C3=ADs Marques
- Steven Schveighoffer (5/6) Jun 17 2014 I want to apologize, that came out sounding condescending, I didn't mean...
- =?UTF-8?B?Ikx1w61z?= Marques" (6/9) Jun 17 2014 No problem. Thanks for clarifying this for me, I was just wanted
- Maxim Fomin (18/23) Jun 17 2014 Actually there is nothing strange because current implementation
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?
Jun 17 2014
On Tue, 17 Jun 2014 11:15:43 -0400, Lu=C3=ADs Marques <luis luismarques.= eu> = wrote:Is there any particular reason why this is accepted? (I introduced it by mistake): void foo(int =3D 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
Jun 17 2014
On Tue, 17 Jun 2014 11:19:46 -0400, Steven Schveighoffer <schveiguy yahoo.com> wrote:Of course this should be accepted.I want to apologize, that came out sounding condescending, I didn't mean it that way. -Steve
Jun 17 2014
On Tuesday, 17 June 2014 at 15:25:22 UTC, Steven Schveighoffer wrote:No problem. Thanks for clarifying this for me, I was just wanted to understand if/why this was useful (most likely scenario), or if it was similar to those cases where the frontend accepts nonsensical declaration qualifiers.Of course this should be accepted.I want to apologize, that came out sounding condescending, I didn't mean it that way.
Jun 17 2014
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.
Jun 17 2014