On Mon, 18 Oct 2010 19:15:47 +0300, F. Almeida <francisco.m.alme...@gmail.com> wrote:

The version() { ... } blocks would greatly improve from support of
boolean operators, which would make code much more readable.

Let us assume, for example, that I have several version identifiers
(VERSION1, VERSION2, VERSION3, VERSION4, etc.) and that a block of
code may be compiled in the cases of VERSION1 or VERSION3. It would
prove the simplest if one could simply use boolean operators to
express combinations of valid versions and thus be able to do


version(VERSION1 || VERSION3)
{
 // ...
}

I remember reading somewhere that this limitation is deliberate.

I believe the reason for this is that programmers with a C background will tend to abuse this feature to create near-unreadable code (#ifdef mess).

The solution (workaround) for this, is to create new versions for specific features you wish to enable/disable. For example:

version(Demo) {} else version(Lite) {} else { version = EnableFeatureX; }
version(EnableFeatureX) { ... }

One thing people seem to agree with is that version statements could use the negation (!) operator. Then the above could be written as:

version(!Demo) version(!Lite) { version = EnableFeatureX; }

--
Best regards,
 Vladimir                            mailto:vladi...@thecybershadow.net

Reply via email to