Uncallable delegates

Timon Gehr timon.gehr at gmx.ch
Thu May 14 21:55:45 UTC 2026


On 5/14/26 21:34, Walter Bright wrote:
> On 5/13/2026 1:30 PM, Dukc wrote:
>> Returning to the DIP, the issue with the present rules are that 
>> calling a `const` delegate (or equally `immutable`, `shared` or 
>> `inout` delegate) without the `const` for the context parameter is 
>> allowed. It shouldn't be, just like the equivalent function pointer 
>> rewrite we just discussed isn't. My DIP is proposing disallowing it, 
>> along with changes to the qualifier casting rules of delegates.
> 
> I'm glad we are understanding each other better.
> 
> I'm not convinced the proposed change improves things.

FWIW, I am convinced that Dukc has the right idea about delegate typing, 
and the proposed change certainly improves things. Though I guess the 
unsound `pure` factory function interaction will remain intact with the 
DIP as written. (Which is partially my bad, I did not consider the 
potential convertibility from mutable to `immutable` when deriving the 
soundness condition in the idea thread.)


More information about the dip.development mailing list