Fix joiner output for infinite range of ranges #871

Merged
merged 1 commit into from Oct 18, 2012

Conversation

Projects
None yet
4 participants
Member

quickfur commented Oct 16, 2012

Joining an infinite range of finite ranges will also produce an infinite range, not just when joining a range of infinite ranges.

Collaborator

monarchdodra commented Oct 16, 2012

If I provide an empty range of infinite ranges, the resulting joiner will actually be empty :/

There is no way to know this at compile time, so joiner "R-o-IR"can't be defined as infinite.


May I bring into question the actual ability to join infinite ranges? The point is to place a separator between each range, which implies the ability to reach the end of said ranges...

We can support joining infinite ranges ("out of completeness"), but I think it may be smarter to do it in the form of a specialized overload (one that just returns a non-infinite wrapper to a ElementType!RoR, which may or may not be empty depending on RoR's initial emptiness)

Collaborator

monarchdodra commented Oct 16, 2012

May I bring into question the actual ability to join infinite ranges? The point is to place a separator between each range, which implies the ability to reach the end of said ranges...

Actually, it can make sense if the Infinite ranges are also bidirectional. Disregard my above suggestion then.

Member

jmdavis commented Oct 16, 2012

Actually, it can make sense if the Infinite ranges are also bidirectional. Disregard my above suggestion then.

Yeah, but infinite, bidirectional ranges are kind of nonsensical. They're legal, but there's no point in going out of our way to support them. I really don't think that it makes sense for joiner to operate on infinite ranges, because you'd never hit a separator.

Member

quickfur commented Oct 16, 2012

You're right, using joiner on infinite subranges is kinda silly, because you'll never get past the first subrange, so you might as well just return the first subrange and be done with it.

OTOH, it is valid to have infinite ranges of finite subranges. So I guess the code here really should be changed so that the isInfinite check is done on the range of ranges, not on the subranges.

Collaborator

monarchdodra commented Oct 16, 2012

OTOH, it is valid to have infinite ranges of finite subranges. So I guess the code here really should be changed so that the isInfinite check is done on the range of ranges, not on the subranges.

Oh! I thought that was the way it was already actually :p

Yes, definitly, the check should be done on RoR, and only RoR.

Collaborator

monarchdodra commented Oct 17, 2012

This change now looks 100% valid to me. Recommend pulling (after a squash).

Member

quickfur commented Oct 17, 2012

Rebased & squashed.

@quickfur quickfur Fix isInfinite conditions.
It makes little sense to join a range of infinite subranges, as we'll
never get beyond the first range, and besides, the outer range might be
empty so setting empty=false is wrong. OTOH, it's valid to have an
infinite range of subranges, in which case the output will be infinite.
So that should be the case that's checked for here.
f9182ec

@dsimcha dsimcha added a commit that referenced this pull request Oct 18, 2012

@dsimcha dsimcha Merge pull request #871 from quickfur/joiner_inf_constraint
Fix joiner output for infinite range of ranges
1d375f4

@dsimcha dsimcha merged commit 1d375f4 into dlang:master Oct 18, 2012

1 check passed

default Pass: 9
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment