is this even possible? newbie + mixin template + foreach (allMembers)
Carlos Navarro
carlos.ns at gmail.com
Tue Apr 3 18:49:00 UTC 2018
QUESTION:
Obviously I'm no geting mixins/templates nor traits and I'm
failing miserably to find/identify the right examples or
documentation to help me tackle this thing. What is wrong in this
code? is this pattern sintactically possible? what I'm getting
wrong?
CONTEXT:
I'm a newbie trying to extend a struct using a mixin template
like this one:
struct World {
float rotation;
bool active;
mixin BuildStuff;
}
mixin template BuildStuff() {
foreach(elem; __traits(allMembers, typeof(this))) {
//pragma(msg, elem);
}
} //full example here: https://run.dlang.io/is/OeXS4j
COMPILER OUTPUT:
2.067.1 to 2.071.2: Failure with output:
-----
onlineapp.d(18): Error: declaration expected, not 'foreach'
onlineapp.d(18): Error: declaration expected, not '__traits'
onlineapp.d(22): Error: template member expected
-----
2.072.2 to 2.075.1: Failure with output:
-----
onlineapp.d(18): Error: declaration expected, not 'foreach'
onlineapp.d(18): Error: declaration expected, not '__traits'
onlineapp.d(22): Error: matching '}' expected, not EOF
-----
Since 2.076.1: Segfault and no output
More information about the Digitalmars-d-learn
mailing list