Feedback on Iterable Numbers Proposal?
I like this proposal a lot!
The only thing I'd like to remark is that I can see people getting confused about the exact range that you're iterating over. Some languages provide constructs to include/exclude the last element in the range.
On that note, it might make more sense to add range literals.
On that note, it might make more sense to add range literals.
A Range type seems to me clearer, more powerful, and less magical. Even without syntax, the clarity seems better:
//for-of syntaxfor (const i of Range.upto(5)){ //do something with i }
for(const i of Range.from(3, 15)){ //do something with i }
Whether Range's are a class or it's just a set of iterator constructors depends on what else you can do with it. The larger proposed change does not seem to me like it offsets the confusion introduced by magical syntax (e.g., what is the result of new Array(4)?)
On Sun, Feb 26, 2017 at 7:40 PM, kdex <kdex at kdex.de> wrote:
On that note, it might make more sense to add range literals.
That was my thought as well -- or at least, ranges if not range literals.
(A simple Range
is trivial to implement, but I'd rather see something
ubiquitous.) I don't see any active, inactive, stage 0, or finished
proposals for ranges (they have been discussed:
esdiscuss.org/topic/ranges).
John, to my mind it'd be great to see this same great level of attention-to-detail, research, etc., devoted to ranges. I think iterable numbers would be too limited to be all that useful (although a subset of your proposal would be really simple to add). But I'm just a random guy on the list, no idea if the people who actually matter would be interested in a range proposal. Ranges have been put to good use in other languages/environments (some mentioned in your proposal), so...
-- T.J.
On Sun, Feb 26, 2017 at 7:40 PM, kdex <kdex at kdex.de> wrote:
On that note, it might make more sense to add range literals.
On 26 February 2017 at 20:50, T.J. Crowder <tj.crowder at farsightsoftware.com> wrote:
That was my thought as well -- or at least, ranges if not range literals. (A simple
Range
is trivial to implement, but I'd rather see something ubiquitous.) I don't see any active, inactive, stage 0, or finished proposals for ranges (they have been discussed: esdiscuss.org/topic/ranges).John, to my mind it'd be great to see this same great level of attention-to-detail, research, etc., devoted to ranges. I think iterable numbers would be too limited to be all that useful (although a subset of your proposal would be really simple to add). But I'm just a random guy on the list, no idea if the people who actually matter would be interested in a range proposal. Ranges have been put to good use in other languages/environments (some mentioned in your proposal), so...
I'd like to bring us back a decade for a while:
Lars T Hansen 2007/07/16 13:33
Multi-dimensional arrays
Consider matrices of floating-point numbers, which we can type as [][double], allocate using x = new []double, and dereference as x[1][5]. We can extract subarrays using x[2:4][1:3], maybe (creating a 2×2 matrix). This should not be important for ES4 but it might be important to make sure we can consider it for ES5, somehow.
And web.archive.org/web/20160425221208/http://wiki.ecmascript.org/doku.php?id=discussion:slice_syntax
The combining of these two features would be a match made in heaven, and be able to provide Ranges.
Howdy!,
My name is John and I have a (hopefully non-contentious) addition for the ECMA Script Language described here: johnhenry/make-numbers-iterable. I wonder if there are good folks out there willing to give me feedback? I also wonder if someone might be willing to champion the proposal as described here: tc39/proposals/blob/master/CONTRIBUTING.md
Thanks,