<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 December 2013 13:45, Maxime Chevalier-Boisvert <span dir="ltr"><<a href="mailto:maximechevalierb@gmail.com" target="_blank">maximechevalierb@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"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It only allocates a closure if (1) it thinks the delegate may escape the scope and (2) uplevel references are used in the delegate.<br>
</blockquote>
<br></div>
The delegate will escape the enclosing scope. I'm wondering if there will still be some kind of scope object allocated to represent escaping values in the englobing stack frame, even when there are no escaping values.<br>

<br>
I don't mind paying the small cost of an extraneous null context pointer, but having a whole unnecessary context object allocated seems wasteful.</blockquote><div><br></div><div>If you have no use for the context pointer, then it sounds like what you want is a function pointer, not a delegate.</div>
<div><br></div><div>A delegate is just a function-ptr+context-ptr pair, it is a trivial struct that is passed by value, the same as a dynamic array. The context pointer may be to a stack frame (in case of a closure), or a class object (in the case of a class method pointer).</div>
<div>If you intend a null context pointer (ie, function doesn't reference any state), than what you really have is a function pointer, not a delegate. You should use a function pointer instead.</div><div><br></div><div>
Can you show your usage?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I strongly suggest trying out a couple examples, and disassembling the result to confirm.<br>
</blockquote>
<br></div>
I'll look into that.<br>
</blockquote></div><br></div></div>