Daniel Kozák <kozzi11@gmail.com> napsal Pá, led 13, 2017 v 10∶29 :<br>
<blockquote type="cite">André Puel via Digitalmars-d <digitalmars-d@puremagic.com> napsal Pá, led 13, 2017 v 10∶15 :<br>
<blockquote type="cite"><div class="plaintext" style="white-space: pre-wrap;">One thing that I miss sometimes when doing meta programming is being able to hide that a function should be called with mixin.
For example (pardon my lack of creativity):
// Instead of
string declare_a() {
return "int a;"
}
int func() {
mixin(declare_a);
return a;
}
// Could we have?
mixin declare_a() {
return "int a;";
}
int func() {
declare_a;
return a;
}
I think this could be useful when one is creating Idiom and Patterns, you could hide implementations details.</div></blockquote><br><div>You can do this:</div><div><br></div><div><div>mixin template declare_a()</div><div>{</div><div> int a;</div><div>}</div><div><br></div><div>int func()</div><div>{</div><div> mixin declare_a;</div><div> return a;</div><div>}</div></div><div><br></div><div>but there is no way to exclude mixin before calling declare_a, there is a good reason for that (it is really important to be able to tell when you use mixin and when not)</div></blockquote><br><div>Right now you can even use</div><div>template declare_a() {...}</div><div><br></div><div>there is no difference between template and mixin template</div>