version(number) is completely useless

Hipreme msnmancini at hotmail.com
Wed Jul 20 16:26:28 UTC 2022


On Wednesday, 20 July 2022 at 14:37:59 UTC, Andrey Zherikov wrote:
> On Wednesday, 20 July 2022 at 13:49:40 UTC, Steven 
> Schveighoffer wrote:
>> version(MyLibrary.5) ... // library version
>> version(MyLibrary_protocol.5) ... // protocol version.
>
> 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)`.

That's why I said about SDL.2.5
It will be compatible to all version until SDL.2.0
That is more than enough for that, specially because breaking 
changes you could put under a new major versions, and if they're 
not compatible, you will be declaring another version rather than 
a number. The problem is exactly that which the best solution 
right now is doing like Mike has done.

I'm only suggesting that because trying to replicate newer 
version has access to older versions is painful and have lots of 
boilerplate code which could be solved with metaprogramming. But 
importing a module for doing this hack doesn't feel very hygienic




More information about the Digitalmars-d mailing list