[Issue 9149] Disallow converting delegates to const

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 25 12:57:40 PDT 2016


--- Comment #13 from timon.gehr at gmx.ch ---
(In reply to Steven Schveighoffer from comment #12)
> Yes I see.
> The issue is the conversion of the delegate type, when the context pointer
> is changed to const (but you didn't change the function pointer, so it still
> assumes it's argument is mutable).
> I agree with you.
> So basically, any struct or class instance cannot convert to const (or via
> pure constructor to immutable)

Do you have an example where conversion to immutable for a strongly pure
constructor leads to problems?

> if it contains a non-const delegate. Yuck,
> but I think we have to do that.

We can't (for class references, you never know whether some subclass might have
a mutable delegate field). We need to do something else, but all options I have
proposed so far are quite ugly (or become ugly when considering all the details
required to make them work), so I'm open to different proposals.


More information about the Digitalmars-d-bugs mailing list