<div class="gmail_quote">On Thu, Jan 13, 2011 at 5:30 AM, Dmitry Olshansky <span dir="ltr"><<a href="mailto:dmitry.olsh@gmail.com">dmitry.olsh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 13.01.2011 2:16, Guilherme Vieira wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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?)<br>

</blockquote>
<br></div>
Ehm, it can optimize certain cases but for the moment it doesn't.<br>
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 ...<br></blockquote></div><br>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 <span style="font-family: courier new,monospace;">(Switch.State state) { this.toggled = cast(bool)(state); }</span> (or something of similar effect).<br clear="all">
<br>-- <br>Atenciosamente / Sincerely,<br>Guilherme ("n2liquid") Vieira<br>