skinny delegates

Mathias Lang pro.mathias.lang at gmail.com
Fri Aug 3 03:41:33 UTC 2018


On Monday, 30 July 2018 at 21:02:56 UTC, Steven Schveighoffer 
wrote:
> Would it be a valid optimization to have D remove the 
> requirement for allocation when it can determine that the 
> entire data structure of the item in question is an rvalue, and 
> would fit into the data pointer part of the delegate?
>
> Here's what I'm looking at:
>
> auto foo(int x)
> {
>    return { return x + 10; };
> }

This is something I've been wanting for a long time as well. It 
was also implemented in Ocean ( 
https://github.com/sociomantic-tsunami/ocean/blob/e53ac93fbf3bfa9b2dceec1a2b6dc4a0ec7f78b2/src/ocean/core/TypeConvert.d#L249-L311 ).
AFAIK it should be possible, although not trivial to do.


More information about the Digitalmars-d mailing list