Allow empty field function arguments for default?

Christophe travert at phare.normalesup.org
Mon Apr 23 01:05:22 PDT 2012


"Jakob Ovrum" , dans le message (digitalmars.D.learn:34971), a écrit :
> That is exactly the problem though, it can silently change the 
> behaviour of existing code. It is the worst kind of breaking 
> change, hence I don't think it will ever be in D in this form, 
> much less the current iteration of the language.

Hum, an acceptable solution would be to give an error, asking to 
explicitely asking to fully qualify the name :

void fun(int c = 0) {...}

void main()
{
  int c;
  fun(c=5); // error, ambiguous qualifier "c"
  fun(main.c = 5); // ok
  fun((c=5)); // ok
  fun(fun.c = 5); // ok, but different meaning.
}

But still, raising an arror is not backward compatible.

-- 
Christophe


More information about the Digitalmars-d-learn mailing list