Re: static version proposal

2011-09-23 Thread Daniel Murphy
"Gor F. Gyolchanyan" wrote in message news:j5i2kv$2abh$1...@digitalmars.com... > Not exactly. > You'll also need to include code, which checks if the symbol API_VER is > defined > before checking it's value. This will make the code bloated. One way to do > it is > to define a template which tak

Re: static version proposal

2011-09-23 Thread Gor F. Gyolchanyan
Not exactly. You'll also need to include code, which checks if the symbol API_VER is defined before checking it's value. This will make the code bloated. One way to do it is to define a template which takes the symbol in the form of a string, but that would look very ugly.

Re: static version proposal

2011-09-23 Thread Gor F. Gyolchanyan
The same way C/C++ does it: put it into a single .di file and import it from both implementation and client code.

Re: static version proposal

2011-09-23 Thread Daniel Murphy
This is the way to do it in D: // -- first module -- module first; enum USE_MY_API = true; /* * My API implementation. */ // -- second module -- module second; import first; static if (USE_MY_API) { // My API usage. } One idiom used in C/C++ is #if API_V

Re: static version proposal

2011-09-23 Thread Trass3r
Yep, I'd also like defined versions to be global, but the problem is this introduces an order-of-evaluation issue. What if module second is processed before module one? Also what if you compile each module separately with -c?

static version proposal

2011-09-23 Thread Gor F. Gyolchanyan
So many times did i feel the need for this feature: // -- first module -- module first; static version = MY_API; /* * My API implementation. */ // -- second module -- module second; import first; version(MY_API) { // My API usage. } The behavior is exact