What about an identifier that is an mixin
Daniel Kozák via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 13 13:29:28 PST 2017
André Puel via Digitalmars-d <digitalmars-d at puremagic.com> napsal Pá,
led 13, 2017 v 10∶15 :
> 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.
You can do this:
mixin template declare_a()
{
int a;
}
int func()
{
mixin declare_a;
return a;
}
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20170113/603f7a3e/attachment.html>
More information about the Digitalmars-d
mailing list