skinny delegates

kinke noone at nowhere.com
Thu Aug 2 19:57:10 UTC 2018


On Thursday, 2 August 2018 at 15:12:10 UTC, Steven Schveighoffer 
wrote:
> On 8/2/18 11:00 AM, Kagamin wrote:
>> I suppose it's mostly for mutability, so if it's const, it can 
>> be optimized based on type information only:
>> 
>> auto foo(in int x)
>> {
>>     return { return x + 10; };
>> }
>
> I'm not sure what you mean here.

I think he's saying that the check for immutability could simply 
consist in checking that all captured variables (well, not too 
much room for a lot of them ;)) have a const type.

It's definitely an interesting idea, and the obvious benefit over 
a library solution is that you wouldn't have to think about this 
optimization when writing a delegate; if the captured stuff 
happens to be const and fit into a pointer, the GC won't be 
bothered, nice.


More information about the Digitalmars-d mailing list