Thin delegate adapter

Guilherme Vieira n2.nitrogen at gmail.com
Fri Jan 14 04:58:44 PST 2011


On Thu, Jan 13, 2011 at 5:30 AM, Dmitry Olshansky <dmitry.olsh at gmail.com>wrote:

> On 13.01.2011 2:16, Guilherme Vieira wrote:
>
>> No sh*t..?! @__@ That's so cool! But is it smart enough to know the stack
>> frame doesn't need to go to heap in this case? (since it returns a heap
>> object referecing another heap object, i.e. can it untangle `b' from the
>> stack?)
>>
>
> Ehm, it can optimize certain cases but for the moment it doesn't.
> Still, it needs to store b somewhere, right? and delegate is 2 pointers in
> fact, so b should go on heap anyway. So it narrows down to if it can save
> only parts of the stack frame ...
>

Since it only uses something the size of a pointer (`b'), it might as well
do some trickery and use `b' as `this' and turn the delegate into (Switch.State
state) { this.toggled = cast(bool)(state); } (or something of similar
effect).

-- 
Atenciosamente / Sincerely,
Guilherme ("n2liquid") Vieira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110114/09daacd6/attachment.html>


More information about the Digitalmars-d mailing list