Compile time only delegates
Frustrated
Frustrated at nowhere.com
Tue Mar 25 11:05:46 PDT 2014
Due to a previous issue I am trying to do the following
mixin template A()
{
mixin((function () => "int x;")() );
}
the problem is that the compiler will not let me use the delegate
because it has no this context. Of course the whole point here is
that the delegate will never be used at runtime since it is used
in the mixin(which is purely compile time).
It should work(there is no reason it shouldn't) yet it doesn't.
The goal is that I do not want to create a function outside the
mixin to use because it will be included in the context of the
template mixin. e.g.,
mixin template A()
{
string B() { return "int x;"; }
mixin(B()); // still doesn't work but if it did B would be
inserted in the context of the template. e.g., if used in a class
the class would then have a method named B in it, hence the use
of the lambda.
}
More information about the Digitalmars-d-learn
mailing list