-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Consistency with Number.range model #120
Comments
To clarify: I very much want Intl.Segmenter to go to Stage 3, and I am happy with the status quo of the proposal, regardless of how we go on Number.range. I opened this issue in order to highlight a potential inconsistency in how we deal with iterator factories in the standard library. I leave it up to others to determine whether this is something worth pursuing. |
I have read the README and the rendered spec, but have not yet read the existing issues. My apologies if I have misunderstood some important aspect. These are my initial thoughts.
My thoughts are about consistency with the
I suspect Regarding renaming
Alternatively, Regarding caching in a polyfill/shim implementation: without a
I see no particular reason to standardise on returning either an |
I truly agree with @Andrew-Cottrell . The only thing I need to add is, even I also feel |
While it is often the case that we want to operate on the same operands in multiple scopes, I don't think proposals should eagerly specify new types that only serve to close over operands, unless there is a clear benefit such as interoperability or performance. One can create iterable objects in user code without much difficulty.
|
Yes, it's easy to create iterable, but only make sense when people understand all such things. On the other hand, I don't see any lost of returning iterable. |
@Jack-Works has been working on https://github.com/tc39/proposal-Number.range, in which the method returns an Iterator directly, rather than an object implementing
Symbol.iterator
. This topic has not been decided (see tc39/proposal-iterator.range#22), but it is up for discussion again at the July TC39. The arguments in favor of this model are mostly around the ergonomics: you can use Iterator methods like.take()
on the return value directly, rather than calling[Symbol.iterator]
or wrapping the return value inIterator.from
.We switched from this model to the model with the intermediate immutable type
%Segments%.prototype
due to concerns I raised in #93, which still stand.If, and only if, Number.range settles on the "direct-to-iterator" model, then I wanted to think about an alternative API for Intl.Segmenter. What would you think about,
Intl.Segmenter.prototype.segment
to return a%SegmentIterator%
like it did before.split()
, likeString.prototype.split
Intl.Segmenter.prototype.segmentContaining
that returns the segment data objectThe cookbook examples in the README would change to:
Also, now that we are diminishing the functionality of
%Segments%.prototype
due to SES concerns, the case for a standalone type is weaker.I'm not sure what this would mean for performance. With
%Segments%.prototype
, the engine has a place to cache info from call to call. Maybe with this new model, the browser can cache things based on the input string.CC @littledan @rbuckton @hax @mpcsh @Andrew-Cottrell @gsathya @devsnek @tabatkins
The text was updated successfully, but these errors were encountered: