version(number) is completely useless
Mike Parker
aldacron at gmail.com
Wed Jul 20 14:46:40 UTC 2022
On Wednesday, 20 July 2022 at 14:37:59 UTC, Andrey Zherikov wrote:
>
> What I don't like here is an assumption that `MyLibrary.5` is
> compatible with `MyLibrary.4`,`MyLibrary.3` etc. This might not
> be the case: versions might be backward incompatible so you
> will have to do `version(MyLibrary.5 && !MyLibrary.4 &&
> !MyLibrary.3 && !MyLibrary.2 && !MyLibrary.1)`. And here are
> the problems: we don't wave `&&` (yes, you can substitute it
> with multiple `version`) and `!` (you have to do `version(bla)
> {} else {...}`). All these workarounds keep me away from using
> `version` - the only thing I use is `version(unittest)`.
You can use version in conjunction with enums as I do in my
bindbc packages, e.g.
https://github.com/BindBC/bindbc-opengl/blob/master/source/bindbc/opengl/config.d.
Then you can use whichever logical operators you want on the
enums with static if to test for library versions at compile time.
More information about the Digitalmars-d
mailing list