Closed waj closed 4 years ago
@waj FWIW, I believe that a compound keyword is more apt in this case than intersection. I'd use compound requirement - as in bundler, see:
Composer calls them version ranges.
They also seem to allow ||
together ranges. >=1.0 <1.1 || >=1.2
.
@Blacksmoke16 I don't know about the Composer, but they're not ranges, that's for sure :)
@Sija How is it not? >= 1.0.0, < 2.0
would be 1.0.0...2.0.0
, i.e. any version greater than or equal to 1.0.0
but less than 2.0.0
.
@Blacksmoke16 because >= 1.0.0, < 2.0, != 1.1
@Sija Still could be interpreted as 1.0.0...1.1.0 || 1.2.0...2.0.0
. π€·.
@Blacksmoke16 Yeah, that's a compound (range) statement you've got there...
I prefer the word "intersection" because it's more explicit about how the expressions are composed. In the future, if we add other operators like ||
or ...
the text can be rephrased.
@waj That's not intersection though... And the comma used there is analogous to &&
(and) logical operator.
@Sija It's the intersection of the version sets defined by each expression. In math intersection and logical and are very close concepts. Also, I'm not the only one using this term for this: https://dart.dev/tools/pub/dependencies#traditional-syntax
@waj Not if you add !=
operator to the mix.
@Sija Itβs intersection. All comma separated constraints need to be satisfied. Even if != is supported. https://www.siyavula.com/read/maths/grade-10/probability/14-probability-03
If or/union is added later is another matter.
Intersection
The intersection of two sets is a new set that contains all of the elements that are in both sets. The intersection is written as π΄β©π΅ or βπ΄ and π΅β.
Quite likely I'm misunderstanding the term in this context but I don't see any (intersecting) sets here. I mean we have constraints, yes, but not sets.
By set intersection I'd understand having 1.0-1.2, 1.1-1.3
(two ranges - sets with an overlap). OTOH >= 1.0.0, < 2.0
defines a set of versions between 1.0
and 2.0
, which is closer to a range in this case than to a intersection... adding multiple clauses turns that into a compound statement.
But maybe my brain is playing tricks on me π€·ββοΈ
@Sija do you realise we're discussing for a word it doesn't even appear in the documentation, right? It's just the issue name and a spec description at most π
It's not brain tricks. Just different ways to see the same. When you say >= 1.0.0
that's a range too. Just an unbounded range. And a range is a set. And sets can be intersected to create a new set. But while all ranges are sets, not all sets are ranges. For example, >= 1.0.0, < 2.0, != 1.2.3
cannot be expressed as a single range (note that !=
is currently not supported). Still can be interpreted as the intersection of three sets. Or a union of two ranges if you want, but for me it's harder to think in ranges because is more complicated to generalize.
With this merged in, it would be good to add support for !=
operator.
This adds support for version specifiers like:
>= 1.0.0, < 2.0
I need this to implement #365, but I think it's also nice addition. Other dependency managers also support expressions like that.