-
Notifications
You must be signed in to change notification settings - Fork 13
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
Number.range(from) for infinite range #14
Comments
That would also mean that omitting the second argument would implicitly be Infinity. That seems problematic. |
Why do you consider that to be a problem? I think it's a feature. |
The But if there are different thoughts on the overload, maybe it's better to not allow any kind of overload. |
I would prefer explicitness. There is no much benefit to save several keystrokes. |
It seems like there's less support for I will stay on the current design until I consider it more clearly (or it's become a consensus that we should add
Thanks for your suggestion! |
I would suggest using
undefined
in the second parameter (to
) to signal an infinite range. This would elegantly solve theBigInt
problem #8, and seems more consistent to me than the overload that makesrange(n)
equivalent torange(0, n)
.The resulting
Range
instance would basically "not have an.end
", i.e.Number.range(n).end === undefined
.The only downside would be that
for (x of Number.range(a, b))
would no longer desugar to the simplefor (x = a; x < b; x++)
but rather to something likefor (x = a; !(x >= b); x++)
. (I would however prefer to simply offer second desugaring in explanations, namely thatfor (x of Number.range(a, undefined))
≡for (x = a; true; x++)
.)If there is a large want for the isAcceptAlias feature, I would propose having a separate
rangeTo
method, whereNumber.rangeTo(n)
≡Number.range(0, n)
.The text was updated successfully, but these errors were encountered: