On Thursday, 9 February 2017 at 15:00:21 UTC, angel wrote:
On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote:
On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote:
I'm looking for a better way to do this, if possible:

Or actually, maybe this will suite your case better:
```
template namedTool(T, alias Variable)
{
enum namedTool = T.stringof ~ " " ~ Variable ~ " = new " ~ T.stringof ~ ";" ~
                     Variable ~ ".name = \"" ~ Variable ~ "\";";
}

void main()
{
    mixin(namedTool!(Tool, "grep"));
    assert(grep.name == "grep");
}
```

Thanks for trying. I know that it doesn't make much sense but it would have been a cool sugar for the tool class.

Mixins are not good for me because of completion in the IDE.

Reply via email to