DIP30, delegates more destruction for your pleasure
kenji hara
k.hara.pg at gmail.com
Wed Mar 13 20:45:30 PDT 2013
2013/3/14 deadalnix <deadalnix at gmail.com>
>
> It is a tempting idea, but do not work. Consider :
>
> void delegate() immutable a;
> const void delegate() b = a;
>
> This would be forbidden as covariance of function parameters and
> transitivity act in opposite directions.
>
You are misunderstanding about delegate type syntax and transitivity.
1. This qualifier for delegate type should be added after parameter types.
const void delegate() b; // bad, typeof(b) == const(void deelgate())
void delegate() const b; // good, b can hold const method
2. A delegate which has immutable context cannot implicitly convertible to
const context delegate.
In general, if a delegate can implicitly convertible to another, there
should be _contravariance_ of parameter types.
void delegate() immutable a;
void delegate() const b;
b = a; // bad
a = b; // good
Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130314/5d47a1a4/attachment-0001.html>
More information about the Digitalmars-d
mailing list