It seems pure ain't so pure after all

Tommi tommitissari at hotmail.com
Mon Oct 1 13:23:17 PDT 2012


On Monday, 1 October 2012 at 20:16:09 UTC, Steven Schveighoffer 
wrote:
> 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.




More information about the Digitalmars-d mailing list