On 7/29/16 2:38 AM, 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)));

s is a runtime parameter. You can't mixin stuff that is only available at runtime.

alias foo2(string s) = Alias!(mixin(generateCode(s)));

This would work if the string is "main", let's say.

string generateCode(string s){return "";}

void main()
{
  enum s = "a = 2 + 3; b = 4 + a;";

This does not result in a symbol, an alias needs a symbol.

-Steve

Reply via email to