version vs. static if

Gor F. Gyolchanyan gor.f.gyolchanyan at gmail.com
Fri Sep 23 08:14:35 PDT 2011


I suggest to rewrite the version functionality as follows.
Replace all existing functionality regarding version with a single compile-time
built-in construct (much like the `is` expression)

version(/* boolean expression */)

, which will returns true if all symbols withing the expression are defined
(including identifiers) and the expression yields true.

then, the process of version tracking will look like this:

enum MY_API = true;
enum MY_API_VERSION = 4;

static if(version(MY_API) && version(MY_API_VERSION >= 2))
{
   // ...
   // Note, that if either MY_API or MY_API_VERSION is not defined, the static
if's expression will be false.
}


More information about the Digitalmars-d mailing list