DIP30, delegates more destruction for your pleasure

deadalnix deadalnix at gmail.com
Fri Mar 15 07:03:55 PDT 2013


On Thursday, 14 March 2013 at 21:29:26 UTC, Timon Gehr wrote:
> int foo(int delegate() dg){ return dg(); }
>
> void main(){
>     foo(delegate()=>2); // error, int delegate()pure immutable
>                         // does not convert to int delegate()
> }
>

OK, is it possible to consider naked delegate as const(void*) 
then ?

I think we should go for the usual instead of the covariant one 
as you propose. The regular will happen anyway and it is quite 
hard to keep everything together without introducing annoying 
rules.

For instance :

class Foo {
     delegate() bar;
}

Foo f = new Foo();
d.bar = { ... }
const g = f;
g.bar(); // ???


More information about the Digitalmars-d mailing list