Can I do an or in a version block?

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Mar 8 06:19:37 PST 2012


I find it interesting that having this feature would somehow "enable"
abuse, yet we can do so much abuse already with CTFE, templates, and
string mixins. One large pain in the ass is to pass an integral at
compile time. I sometimes wish to use a syntax such as "version(foo ==
5) {}". The only alternative that I know of is to use string imports
via -J switch to initialize an enum. Compare that with the simple
-Dfoo=5 in DMC/GCC/etc. We might not have globals or macros in D, but
at least 'version(foo) = 5' or something similar should work. It's
also strange that version uses its own meaning of the equals operator,
I really dislike that.

Generally it seems version is the poorest-developed feature of D. And
the counterargument for new features is always a Go-like stance ("you
just won't need it"/"people will abuse the feature").

Of course all I can do now is whine and not propose something better.
:) But there have been a few threads about version and its issues. I
think it's only a matter of time before D gets popular enough that we
get these kinds of threads every other day. Maybe then something will
change.


More information about the Digitalmars-d-learn mailing list