Casting functions to delegates

Matthias Walter xammy at xammy.homelinux.net
Sat Dec 11 20:25:10 PST 2010


Hi all,

there was a discussion in 2006 but w/o a result, and I didn't find any
bugs about implicitely casting functions to delegates. It seems to be
impossible as long as function-pointer calls work differently than
delegate calls in the ABI. Will this at some point be fixed?

If not, is there a conversion function in phobos (I didn't find one)? I
played a bit and found that this one might work:

R delegate(A) funcionToDelegate (R, A...) (R function(A) func)
{
  return (A a){ return func(a); };
}

Matthias


More information about the Digitalmars-d mailing list