-
Notifications
You must be signed in to change notification settings - Fork 156
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
fast/short array creation syntax #1107
Comments
Possible complications of introducing a new syntax might be upheld by "you may ignore it if you find it unhandy" claim, but eventually it will concern every one of us because we eventually will have to read someone else's code. The richest "language" regarding to the "shorthand" is possibly the RegEx. It's considered as a "write-only language". So, I prefer not to have it at all. That's of course only my idea. |
Isn’t that just |
works well when repeatArray$([x], n);
function repeatArray$(arr, n){
for (var r = []; n > 0; (n >>= 1) && (arr = arr.concat(arr)))
if (n & 1) r.push.apply(r, arr);
return r;
} Isn't it way too arcane? :] how do you create and fill/initialize array? PS: oh, it's actually in the docs, operators -> List section.. didn't know |
In a version of LiveScript that assumed (or was instructed to have) an ES6 target, I think it could make sense to optimize specifically Absent such a version of LiveScript, this doesn't seem that important to do; writing |
So you mean that LiveScript should be upgraded to have some compile option that enables higher JS/ES runtime versions first? |
I'm not saying such a compile option would necessarily be a good idea. (A while back there was some talk about integrating LiveScript with Babel (#821), which I think would be a better approach for targeting more modern runtimes.) But to take a compilation that targets ES5 (or is this even ES3?) and change it to only run on ES6 is more breaking than I want to do without some sort of a bigger plan for ES6+ support in general. If such a plan ever comes into play, I think I'd be happy for this optimization to be a part of it. |
any ideas of making fast array creation/fill syntax?
here is the target javascript code:
where
n
is the number of elements, andx
is the fill value. maybe:The text was updated successfully, but these errors were encountered: