http://d.puremagic.com/issues/show_bug.cgi?id=5710
--- Comment #22 from Steven Schveighoffer <schvei...@yahoo.com> 2013-05-06 18:10:18 PDT --- (In reply to comment #21) > The problem with Rainer's idea is that the callee would need to know the > layout > of the stack frame in the context in which the delegate was bound, which in > general it cannot know. The generated function MUST know the context of main, or else it can't call add. Remember, add is passed as an alias, not a delegate. Even if add is passed as a delegate, it's calling the delegate from main's stack-frame (i.e. two identical calls separated by a re-assignment of the delegate would call two different functions). Bear in mind that each call to doStuff with a different alias is a *different* instantiation, even for calls with the same inner function types because of the alias parameter. It is OK for each instantiation to be aware of the stack offset for 'this'. And it's 2 extra words, not 1. You need to store the 'array of context pointers' on the stack, which you do not need if you know the layout of the stack frame. If you think about it, it is actually very little different from Kenji's idea: uint doStuff(uint a, uint b, void** this) // not void* this { // (*this + 0) points the object Foo // (*this + 1) points the stack frame of main() Rainer's: uint doStuff(uint a, uint b, void* this) { // this points the stack frame of main() // *(this + N) points the object Foo Note the difference is that N is a compile time constant, like Kenji's 1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------