Improving version(...)

Rainer Deyke rainerd at eldwood.com
Mon Oct 18 15:30:27 PDT 2010


On 10/18/2010 13:42, Tomek Sowiński wrote:
> template isVersion(string ver) {
>     enum bool isVersion = !is(typeof({
>           mixin("version(" ~ ver ~") static assert(0);");
>     }));
> }
> 
> static if (isVersion"VERSION1" || isVersion!"VERSION3") {
>     ...
> }
> 
> If you're rushing to reply "That's hideous!", don't bother. I know.

Hideous?  That's beautiful!  It lets me pretend that the ugly,
restrictive, pointless "version" construct in the language didn't exist,
while still reaping the benefits of the version construct.  If I ever
write a style guide for D, it will forbid the direct use of 'version'
and require that 'isVersion' be used instead.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list