#2364 Pessimistic Versioning with Depend

SlimerDude Thu 16 Oct 2014

I believe the documentation for Depend is lacking and needs revising, for it doesn't explain in a clear fashion how to do pessimistic versioning...

As a pod producer, my libraries depend on other libraries. For those dependent libraries I want to specify a minimum version of X.Y.Z to get the latest API additions. But following semantic versioning (and common sense) I also want to specify a maximum version of X.Y so I don't pickup any non-backwards compatible changes.

Example, if I depend on version 1.0.14 of library foo then I'm able to use any version of foo 1.0.XX that's greater than or equal to 1.0.14 but not 1.1.XX.

I worked out how to specify this with Depend:

foo := Depend("foo 1.0.14 - 1.0")

foo.match(Version("1.0"))        // --> false
foo.match(Version("1.0.13"))     // --> false
foo.match(Version("1.0.14"))     // --> true
foo.match(Version("1.0.15"))     // --> true
foo.match(Version("1.0.99.99"))  // --> true
foo.match(Version("1.1.0.0"))    // --> false
foo.match(Version("1.1"))        // --> false

I find I want to do this with pretty much every dependency I declare, even core Fantom pods. Example, BedSheet uses Fantom 1.0.66 specific APIs, and I doubt it'll work with a future Fantom 1.1 release - so sys 1.0.66 - 1.0 it is!

As such, it'd be really useful if there was shortcut for this syntax. Ruby has one, although it's twiddle-wakka shortcut makes no logical sense to me. (Neither the name nor the shortcut!)

Personally, I would have liked to have used + to mean increments in that segment only, and ++ to mean an increment in any version segment.

foo 1.0.14+   // pessimistic versioning
foo 1.0.14++  // optimistic versioning

But I fear it's too late for that!

Maybe brackets could be used to limit the effect of the plus symbol?

foo 1.0.(14+) // pessimistic versioning
foo 1.0.14+   // optimistic versioning (as it is now)

What do others think?

LightDye Sat 18 Oct 2014

I prefer the first syntax if it isn't too late

foo 1.0.14+   // pessimistic versioning
foo 1.0.14++  // optimistic versioning

But if it is too late, what about using other symbol for the pessimistic versioning? e.g.

foo 1.0.14^

Or a different position for the + symbol? e.g.

foo 1.0.+14

I haven't needed this level of sophistication, though.

brian Wed 22 Oct 2014

I agree that seems like a bit of hole for a common case. I don't think we really want to break the existing model where the "+" is associated with the entire version. In your case what you are proposing is something like a "+" just on the last segment of the version. Using "^" for that makes sense to me.

But I think before rushing to make any changes to our dependency syntax that we probably really ought to go and and see what people are using across all these package managers and different languages. The current stuff was done a long time ago, and I've never really taken the time to see how this stuff is evolving (if there is some specific conventions typically used, etc)

SlimerDude Sun 26 Oct 2014

I quite liked LightDye's suggestion of ^ too.

if there is some specific conventions typically used

Not that I've seen. Example NodeJs semver is even more messed up than Ruby's (!) and causes a fair bit of confusion. Fantom's current syntax is much more understandable.

Login or Signup to reply.