On Sunday, 26 May 2019 at 17:46:35 UTC, Andrey wrote:
Is it possible to extract code of some function into string variable using CT reflextion?
For example:
int test(bool flag)
    return flag ? 100 : getRandom();

enum string code = GetFunctionCode!test; // "return flag ? 100 : getRandom();"

You can hack this by using import(filename) and importing the file. If you had a good D parser you could potentially do this safely. You must use the -J switch though.

Reply via email to