skinny delegates
Stefan Koch
uplink.coder at googlemail.com
Thu Aug 2 13:21:42 UTC 2018
On Thursday, 2 August 2018 at 12:57:02 UTC, Steven Schveighoffer
wrote:
> On 8/2/18 8:42 AM, Stefan Koch wrote:
>> 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?
>>
>> Don't do that. It's valid in simple cases.
>
> Those are the cases I'm referring to.
>
I meant it seems valid in simple cases, and I doubt you can
distinguish between cases that work and cases which don't work
with 100% accuracy.
>> As soon as you want to chain delegate pointers it falls apart.
>
> And so, don't do the skinny delegate optimization in that case?
>
Again the question is whether you can tell the cases apart with
local information.
>> Also the delegate might require heap allocation to be memory
>> correct.
>
> Does the "might" depend on the caller or on the delegate
> implementation itself? The former would squash this idea.
>
I am not sure about that, it's just a gut feeling that skinny
delegates will be breaking some invariant, I may be wrong.
Coming up with specific rules and throwing them at the wall until
they don't break anymore, is fine for applications used in
limited controlled circumstances, I would not want to do it with
a compiler which is used by an unknown number of users.
More information about the Digitalmars-d
mailing list