-
Notifications
You must be signed in to change notification settings - Fork 469
[RFC] Array spread syntax #6546
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
Comments
Side note, but concat seems to be pretty slow compared to the native array spread. Something we can consider for v12 or when we want to start allowing ES5+ JS. |
Don’t trust micro benchmarks. The performance at scales of “two numbers per array” is so fast either way that it’s irrelevant. With larger arrays spread will naturally be slower because it’s iterating, not just copying. One example I found without much research: |
@TheSpyder that's great! 😄 Sounds like that's not something worth worrying about then. |
Array spreads are quite common in JS land, and they're pretty awkward to do right now in ReScript. You essentially need to do this (using Core):
Which compiles to:
Compiling to
concat
is fine imo, but it'd be great if the ReScript above could be written like this instead:This could parse to the first ReScript snippet using
concatMany
, that's fine.I believe this would be a pretty harmless change (as of now you need to write the exact code it parses to manually) and being a significant gain in ergonomics. Remains to be seen how difficult it is technically (need to account for things like
[1, ...arr1, 2, 3,4 ...arr2]
etc).Thoughts?
The text was updated successfully, but these errors were encountered: