http://d.puremagic.com/issues/show_bug.cgi?id=5710
--- Comment #21 from Diggory <digg...@googlemail.com> 2013-05-06 17:50:32 PDT --- (In reply to comment #20) > (In reply to comment #19) > > > How the parameters are actually passed is fairly irrelevant, the main > > problem > > which needs to be solved is how to store two context pointers in a delegate, > > If you look closely at the original example, no delegates are used. add is > passed by alias, not by delegate. But I see the point, if you took > &foo.doStuff!add, you would be screwed. > > What about Rainer's idea? This would require less memory consumption from the > stack. > 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. If you refine it so that you arrange for part of the stack frame to follow a predefined layout so that the callee knows where to find the "this" pointer, you then need a second pointer to point to the beginning of the stack frame (because it may not be possible to place this structure at the start of the stack frame) and you end up with something that is identical to Kenji's solution. It only uses one extra pointer over what would be required if you had a dedicated 2 context pointer delegate type, so I don't think that memory consumption is much of a problem. > Anyone consider that this is no longer the case (in any valid solution so > far)? > > auto dg = &foo.doStuff!add; > assert(foo !is dg.ptr); > > Don't know if that's an unbreakable rule though... That assertion is only currently valid for member function delegates. Nested functions store the frame pointer in "dg.ptr". I would say that "foo" in this case is no longer strictly a member function, but is some weird mix between a member function and an anonymous nested function, so it's perfectly reasonable to expect it to behave differently in that case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------