The most awesome "forward to member" solution?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 3 22:28:03 PDT 2015
On 5/3/15 8:13 PM, Meta wrote:
> On Monday, 4 May 2015 at 01:01:05 UTC, Andrei Alexandrescu wrote:
>> Hmm, I didn't try it assuming it won't work (thought
>> __traits(getMember, member, sym) would fail with opDispatch). Tried it
>> just now, it does work like a charm. Thanks!
>>
>> Andrei
>
> So is a function that generates a string mixin necessary or not necessary?
I'm not sure. It's a great question. In some ways a string mixin is the
straight deal - you get complete control over what you generate,
ultimate flexibility, and you get to inspect it if you so want. (BTW I
think compiler errors in mixins should either print the failing mixin
with line numbers, or make it available as a file).
But then the opDispatch solution is more structured and restricted in a
good way. I think we need a bit more experience with both to figure out
which is the best way to go. More specifically:
* forward to enumerated types
* distinguish static/non-static methods, and define forwarding appropriately
* define properties to forward to member variables
* alias member types and templates
* other similar stuff I didn't think of, in essence "defer stuff to this
member"
Andrei
More information about the Digitalmars-d
mailing list