On Friday, 14 August 2015 at 14:29:38 UTC, Andrei Alexandrescu wrote:
Nice work, though I see it fails to compile if the member does not define the member. I noticed sometimes "dispatchToMemberIfPresent" is useful, too, and allows for flexible composition and good introspection. So having both would be great.

Andrei

"forwardIfDefined" does sound useful. My reasoning for erroring out is that failure is otherwise silent and possibly hard to debug. Having this behaviour be opt-in is certainly useful in some cases though, such as with std.allocator.

I also plan to detect whether the symbol being forwarded to is a function or a field, and generate an @property wrapper as appropriate, which shouldn't be too hard. What *will* be difficult, though, is controlling which overloads are forwarded to. Currently dispatchToMember just picks the first function that matches the name given. What did you have in mind for choosing overloads? I've thought about maybe having a small DSL that allows for choosing overloads, but that could be complicated and not worth the complexity.

Reply via email to