Vladimir Panteleev wrote:
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).

Yes. Unfortunately the current situation doesn't really prevent that.

My opinion (a significant departure from the current situation, unfortunately):
It should be possible to define version identifiers with booleans.

version EnableFeatureX = !Lite && !Demo;
Possibly:
* make it illegal to define a version identifier from inside a version {} block.
* disallow duplicate version definitions.
* require declarations for all version identifiers. Versions which are set from the command line should be explicitly declared, eg:
version Lite = extern;
version Demo = extern;

That would make creating a bird's nest impossible.
And currently, you can make a typo like:
version(Linix) {}
and it compiles happily. I don't like that. Especially when we have builtin names like D_Inline_Asm_X86_64!

Reply via email to