Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interval interface #3661

Closed
DartBot opened this issue Jun 14, 2012 · 11 comments
Closed

Interval interface #3661

DartBot opened this issue Jun 14, 2012 · 11 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-collection type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 14, 2012

This issue was originally filed by @seaneagan


see https://gist.github.com/2719638

One use case is in dart:unittest...

The "contains" matcher could be extended to match against Intervals.
// e.g.
expect(new Interval(0, 100), contains(x));

Then the following matchers could all be removed:

inInclusiveRange
inExclusiveRange
inOpenClosedRange
inClosedOpenRange

Another sensible name would be "Range".

@DartBot
Copy link
Author

DartBot commented Jun 15, 2012

This comment was originally written by @seaneagan


actually, an "in" matcher (issue #3679) would work better than "contains".

expect(x, in(new Interval(0, 100))

@sethladd
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Library-Collections, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Jun 28, 2012

I think it's a good idea. It's basically an immutable collection of integers, which can be useful in various cases. Possibly with some Range-specific extra functionality like "overlaps".
Another possible name is Range, matching the corresponding concept in, e.g., Python or Scala.

@lrhn
Copy link
Member

lrhn commented Jun 28, 2012

Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Jun 28, 2012

This comment was originally written by @seaneagan


I think Range could extend Interval<int> if there were integer specific functionality desired such as iterability, as intervals are useful for all Comparables (e.g. Date intervals), not just integers:

interface Range extends Interval<int>, Iterable<int> {}

@gramster
Copy link

I don't see how an interval would eliminate all four of those matchers. One, yes, but that isn't buying anything.

@DartBot
Copy link
Author

DartBot commented Sep 18, 2012

This comment was originally written by @seaneagan


@gram, here's what I was thinking:

instead of:

inInclusiveRange(0, 5)
inExclusiveRange(0, 5)
inOpenClosedRange(0, 5)
inClosedOpenRange(0, 5)

you would have:

in(new Interval(0, 5, includeMax: true))
in(new Interval(0, 5, includeMin: false))
in(new Interval(0, 5, includeMin: false, includeMax: true))
in(new Interval(0, 5))

alternatively Interval could have named constructors:

in(new Interval.inclusive(0, 5))
in(new Interval.exclusive(0, 5))
in(new Interval.openClosed(0, 5))
in(new Interval.closedOpen(0, 5)) // this could potentially be unnamed

@dgrove
Copy link
Contributor

dgrove commented Jan 11, 2013

Removed Library-Collections label.
Added Library-Collection label.

@DartBot
Copy link
Author

DartBot commented Apr 3, 2013

This comment was originally written by @seaneagan


This could also replace the KeyRange class in dart:indexed_db:

http://api.dartlang.org/docs/bleeding_edge/dart_indexed_db/KeyRange.html

@floitschG
Copy link
Contributor

We discussed this frequently.
In the end the main argument against it, is that ranges and intervals may include or exclude their boundaries. Depending on the context you usually assume one or the other. The additional complexity (API wise or concept wise) pushes it from "we should have it" to "would be nice, but not in core".


Added NotPlanned label.

@DartBot
Copy link
Author

DartBot commented Nov 25, 2014

This comment was originally written by @seaneagan


I added an interval package to pub for this:

https://pub.dartlang.org/packages/interval

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection closed-not-planned Closed as we don't intend to take action on the reported issue labels Nov 25, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-collection type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants