View mode: basic / threaded / horizontal-split · Log in · Help
April 23, 2012
Re: Allow empty field function arguments for default?
"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
April 23, 2012
Re: Allow empty field function arguments for default?
On 2012-04-23 10:05, Christophe wrote:

> 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.

Would the following syntax be backwards compatible:

foo(c: 0)

-- 
/Jacob Carlborg
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home