DIP27 available for destruction

deadalnix deadalnix at gmail.com
Wed Feb 27 02:57:09 PST 2013


On Wednesday, 27 February 2013 at 10:38:05 UTC, Timon Gehr wrote:
>> I considered optional parentheses where you would have an 
>> error, but I'm
>> afraid that this could create weird effect with function 
>> overloads.
>>
>
> There are no weird effects with function overloads in what I 
> propose. What is the issue you are seeing?
>

Consider the following situation :

void foo(uint a) {
     writeln("a is ", a);
}

uint bar() {
     return 0;
}

foo(bar); // a is 0

Later, this function is added :
void foo(uint function() a) {
     writeln("function not executed");
}

The statement above become :
foo(bar); // function not executed

Note that foo can be in other modules, so it may not be obvious. 
It can be solved in various ways, and I actually implemented some 
to play around. I was not satisfied with the result.

>> It may be limited to the case where expression can't be used as
>> statement because it has no effect.
>
> Then it is not worth it.

It would kick in with the example you gave.


More information about the Digitalmars-d mailing list