On 13/01/2011 17:14, %u wrote:
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
%u<e...@ee.com>  wrote:
I only need something to make a void deleg() from a void func().
This works for me:
ReturnType!( F ) delegate( ParameterTypeTuple!( F ) ) toDelegate( F )( F
fn ) {
      return ( ParameterTypeTuple!( F ) args ){ return fn( args ); };
}

What am I doing wrong. I can't call the delegate twice with anything in between.

Every delegate needs a context pointer. If the function is defined within a function, that context pointer points to the stack frame of the function that defined it. And in this case it uses something from that very stack frame: the parameter fn.

ISTM it works straight after you've created it only because the stack frame of toDelegate has not yet been overwritten. However, I'm still puzzled, because the process of calling the delegate ought to itself overwrite the stack frame.

You want this:

http://pr.stewartsplace.org.uk/d/sutil/

Stewart.

Reply via email to