On Friday, 29 July 2016 at 12:11:44 UTC, pineapple wrote:
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?

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é

Reply via email to