`static switch` statement?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Sep 17 01:05:28 UTC 2019


On 9/16/19 6:41 PM, octo wrote:
> `static switch` would make a nice addition to `static if`, `static 
> foreach`, etc.
> 
> Any thoughts?

It doesn't seem to add power to the language. "static try" would be way 
better because a typical idiom is:

static if (__traits(compiles, { codecodecode }))
{
     codecodecode
}

It would be way nicer if we had something like:

static try
{
     codecodecode
}
catch (Exception e)
{
     // e.msg contains the compile-time error
}



More information about the Digitalmars-d mailing list