string mixin and alias
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 29 05:42:16 PDT 2016
On Friday, 29 July 2016 at 12:22:54 UTC, Andre Pany wrote:
> It is more or less syntax sugar. In the main function instead
> of writing "mixin(generateCode(s));" I want to write "foo(s);".
> So, the mixin statement is hidden while the functionality of
> mixin stays.
>
> Kind regards
> André
As far as I know, there's no way to hide away the `mixin`
statement in a template or alias. You could do something like
this, if you really wanted to, but really the only difference is
that it uses fewer parentheses.
string generateCode(string s){return "";}
enum foo(string s) = generateCode(s);
void main(){
enum s = "int a = 2 + 3; int b = 4 + a;";
mixin foo!s;
}
More information about the Digitalmars-d-learn
mailing list