On Thu, Jan 13, 2011 at 5:30 AM, Dmitry Olshansky <dmitry.o...@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

Reply via email to