We already have that, use templates: private auto _funimpl(string s) { /* what was previously in fun(string) */ }template fun(string s) { enum fun = _funimpl(s); } // usage: fun!("times"); // always executes _funimpl at compile time
Yes, I know. And this helps even more:
template ct(alias expr)
{
enum ct = expr;
}
auto fun(string s)
{
...
}
// usage:
ct!(fun("times"))
But that's still a nuisance.
