string mixin and alias

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 29 05:11:44 PDT 2016


On Friday, 29 July 2016 at 06:38:17 UTC, Andre Pany wrote:
> Hi,
>
> is there a way to alias a string mixin?
> Neither foo nor foo2 compiles.
>
> import std.meta : Alias;
> alias foo = (s) => Alias!(mixin(generateCode(s)));
> alias foo2(string s) = Alias!(mixin(generateCode(s)));
>
> string generateCode(string s){return "";}
>
> void main()
> {
>   enum s = "a = 2 + 3; b = 4 + a;";
>   foo(s);
>   foo2(s);
> }
>
> Kind regards
> André

It's not clear what you're trying to accomplish. What would you 
expect this code to do?


More information about the Digitalmars-d-learn mailing list