2012/7/31 Andrei Alexandrescu <[email protected]>: > On 7/30/12 12:25 PM, kenji hara wrote: >> >> Unfortunately no. 'static nested struct' never have any frame pointers, so >> >> auto map(alias pred, Range)(Range r) { >> static struct Result { >> .. auto front() { return pred(...); } >> } >> } >> >> if pred is a nested function and requires its frame pointer to call >> it, Result cannot access it. > > > Got it. So is it correct to say that global structs templated with alias > sometimes save their frame pointers, sometimes not? If so, could you please > give a few more details on how that choice is made?
Yes, that's right. I've post a more detail to explain it. http://d.puremagic.com/issues/show_bug.cgi?id=8463#c7 >>> Longer term, it has become obvious to me that we need a clear and simple >>> mechanism for a function to save another function passed by alias, even >>> if >>> that function holds state. That must happen regardless of interaction >>> with >>> Voldemort types. We must have a mean do e.g. define a scope delegate that >>> holds the alias function and is able to call it. This has been a >>> long-standing problem that we've avoided in limited cases by relying on >>> the >>> built-in frame pointer. >> >> >> The fundamental problem is the same as this. >> >> Issue 5710 - cannot use delegates as parameters to non-global template >> http://d.puremagic.com/issues/show_bug.cgi?id=5710 > > > It would be quite a bummer if we can't address this limitation somehow. I agree, but it seems to me that is fairly difficult... Kenji Hara _______________________________________________ dmd-beta mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-beta
