haxelib version testing #5920

Open
ncannasse opened this Issue Jan 4, 2017 · 7 comments

Projects

None yet

3 participants

@ncannasse
Member

I used (some long time ago) to be able to do the following:

#if (mylib >= 3.2) ... #end

This does not seem to be working anymore with float literal. String literal works however.

@Simn
Member
Simn commented Jan 4, 2017

I think that's a feature, comparing semver versions as float is terrible.

@ncannasse
Member

Could we not simply handle it (by detecting that a semver with a small regexp ?

@ncannasse
Member

(I think we can actually detect 3.1 vs 3.10 since it's at the AST level)

@ibilon
Member
ibilon commented Jan 4, 2017

That's not haxelib specific, all defines are strings, so applying numerical comparison on them doesn't make sense.

Though it would be useful to have,
maybe through a macro call or something? #if @semverGE(mylib, 3.2.0)
which could be useful for advanced conditional compilation without scripting it in bash/equivalent.

@ncannasse
Member

@ibilon I know that defines are strings in Haxe

I think that silently failing on float comparison is much more troublesome than implementing some dynamic comparison. If we assume that 3.3 == "3.3" and compare the float string against the version it should work quite well

@ibilon
Member
ibilon commented Jan 4, 2017

If we assume that 3.3 == "3.3" and compare the float string against the version it should work quite well

Only if there's only one digit though,
and the version also has a patch so equality comparison won't work.

@Simn
Member
Simn commented Jan 7, 2017

If we assume that 3.3 == "3.3" and compare the float string against the version it should work quite well

At the moment the parser does the exact opposite: If it finds TString op TFloat it tries to do (float_of_string TString) op TFloat.

@Simn Simn modified the milestone: 4.0 Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment