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

Normative: Prefix RangeIterator with Numeric #46

Merged
merged 2 commits into from
Feb 26, 2021
Merged

Conversation

Jack-Works
Copy link
Member

@Jack-Works Jack-Works commented Feb 25, 2021

  1. Rename RangeIteratorPrototype to NumericRangeIteratorPrototype.
  2. Rename RangeIteratorPrototype.inclusive to RangeIteratorPrototype.isInclusiveEnd.

(This is not related to #44 or #45, not affecting the main API shape but do observable)

@ljharb
Copy link
Member

ljharb commented Feb 25, 2021

Why “numeric”? What other kind of range would be implied?

What does “isInclusiveEnd” mean versus “isInclusive”?

@Andrew-Cottrell
Copy link

Why “numeric”? What other kind of range would be implied?

The Numeric prefix may be worthwhile if plausible future proposals might define

  • DateRangeIteratorPrototype
  • StringRangeIteratorPrototype
  • EnumRangeIteratorPrototype

@ljharb
Copy link
Member

ljharb commented Feb 25, 2021

Are those plausible?

@Jack-Works
Copy link
Member Author

Why “numeric”? What other kind of range would be implied?

If we're going to have String ranges in the future, we won't collide the name.

What does “isInclusiveEnd” mean versus “isInclusive”?

It means, the property only indicates the end is inclusive or not. The start is always inclusive

@Andrew-Cottrell
Copy link

Andrew-Cottrell commented Feb 25, 2021

Are those plausible?

I don't know, but I can conceive of them. However, if I wanted to range over some ordered type, one approach would be to map a suitable range of numbers; for example

let animals = Number.range("🐀".codePointAt(), "🐉".codePointAt(), {inclusive: true}).map(String.fromCodePoint);
for (let animal of animals) console.log(animal); // 🐀 🐁 🐂 🐃 🐄 🐅 🐆 🐇 🐈 🐉

which could conceivably be written as

let animals = String.range("🐀", "🐉"); // function might also accept an optional `Intl.Locale` or `Intl.Collator`
for (let animal of animals) console.log(animal); // 🐀 🐁 🐂 🐃 🐄 🐅 🐆 🐇 🐈 🐉

Perhaps those prototypes are unnecessary; even if they are conceivable.

@devsnek
Copy link
Member

devsnek commented Feb 25, 2021

String.range('a', 'z') could theoretically exist.

@ljharb
Copy link
Member

ljharb commented Feb 25, 2021

@devsnek i don't see how, would that include ü, for example?

@devsnek
Copy link
Member

devsnek commented Feb 25, 2021

@ljharb in the event I propose String.range I'll answer that question :)

@Jack-Works
Copy link
Member Author

I'll revert the rename on isInclusiveEnd because I want to match the name in the options bag

@Jack-Works Jack-Works merged commit f5404e8 into master Feb 26, 2021
@Jack-Works Jack-Works deleted the rename-spec branch February 26, 2021 02:50
@ljharb
Copy link
Member

ljharb commented Feb 26, 2021

To restate: i don't think any non-numeric ranges are viable, and i think the "numeric" prefix is unnecessary.

@Jack-Works
Copy link
Member Author

To restate: i don't think any non-numeric ranges are viable, and i think the "numeric" prefix is unnecessary.

Why not? Why can't we have a "Temporal" range like Temporal.range(day1, day3) in the future?

@ljharb
Copy link
Member

ljharb commented Feb 26, 2021

Temporal.Duration already exists, there’d be no need for it on Temporal itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants