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
BlockBindingTransform should not use try/catch always #6
Comments
From arv@chromium.org on June 23, 2012 20:30:08 I think if the following are true we could change it to a var
I think 2 and 3 can be achieved by renaming the binding |
From edy.b...@gmail.com on January 18, 2013 06:12:54 I think there's a v8 issue for this, and I also remember them saying something on the lines of "we could probably enable some optimizations, but right now we have none inside try/catch". I doubt it's the first time you hear about it, so here's my 4th option: add an option to generate let keywords in the output, as SpiderMonkey and v8 (with some flags) support it. |
From edy.b...@gmail.com on January 19, 2013 11:49:45 |
From arv@chromium.org on January 20, 2013 18:28:45 traceur.options.blockBinding = 'parse'; Most Traceur options are tri state (true, false and 'parse'). When the option is set to 'parse' the feature is parsed but not transformed. If you find any bugs related to "traceur.options.blockBinding = 'parse'" please file a new bug since this is definitely something we want to have fully working. |
From olov.las...@gmail.com on February 07, 2013 08:02:22 |
From arv@google.com on February 07, 2013 15:18:02 var fs = []; maybe this is limited to loops? I can't think of any non loop case. |
From olov.las...@gmail.com on February 07, 2013 20:17:38 |
From #297:
Since |
Another idea would be to replace assignments to the iterator so they assign both the scoped iterator and the original one. That won't require the |
Is this something hard to do? AngularJS 2 currently doesn't use |
This is not that hard. It is easier than some of the transformations we already do and harder than others. It is just a matter of lack of time from my side. |
Out of curiosity, would a function wrapper with all the function foo() {
var bar = 2;
let array = []
for (let i of x) {
let {prop} = i;
array.push(prop + bar);
}
try {
prop == null;
} catch (e) {
return array;
}
throw new Error();
}
// to...
function foo() {
var bar = 2;
var array = []; // wrapping this is useless
for (var i$ in x) {
(function (i) { // copy index, now it's local to the loop
var prop = i.prop; // wrapping this is useless
array.push(prop + bar);
})(x[i$]);
}
try {
prop == null; // should throw
} catch (e) {
return array;
}
throw new Error();
} I know this example is relatively |
@IMPinball That is pretty much what we are doing now: function f() {
var fs = [];
for (var i = 0; i < 10; i++) {
let x = i;
fs[x] = () => x;
}
x; // throws ReferenceError: x is not defined
}
f() Generates: function f() {
var fs = [];
var $__104 = function(i) {
var x = i;
fs[x] = (function() {
return x;
});
};
for (var i$__103 = 0; i$__103 < 10; i$__103++) {
$__104(i$__103);
}
x;
}
f(); Closing this in favor of #1277 |
Original author: jmesserly@google.com (April 15, 2011 22:37:37)
Currently BlockBinding is always generated with try/catch. We should try to use functions when possible.
Original issue: http://code.google.com/p/traceur-compiler/issues/detail?id=3
The text was updated successfully, but these errors were encountered: