(but oh gods 'let' makes me so happy, having to get sensible closure behaviour by typing out let-over-lambda shenanigans by hand was -ing horrible)
(but oh gods 'let' makes me so happy, having to get sensible closure behaviour by typing out let-over-lambda shenanigans by hand was -ing horrible)
Furthermore, there is already a compiler that implements first class delimited continuations in JavaScript: http://stopify.org
The project implements the control operator (which can implement other operators like call/cc). The research paper linked on the website talks about how control is implemented.
That's fair, agreed, and I don't mean to imply equality. The argument was that JS doesn't have continuations at all though, which wasn't completely true in 2013, and is trending less true over time with promises and generators, right?
Some might argue that a function which is so long that it needs block scoping, whether for visibility or storage lifetime management, is too long.
I guess it’s at least “mostly harmless”, though :-)
(“class” arguably sucks in ES2015)
for (let x in list) {
callbacks.push(function () { x+3 });
}
instead of: for (var x in list) {
callbacks.push((function (x) {
function () { x + 3 }
})(x);
}
is a huge advantage to me. (yes, I know arrow function notation exists, but given I was explaining "why I love let" it would've been unfair to use it in the "good" example)OTOH:
list.forEach( function( x ) {
callbacks.push( function () { return x + 3 } )
}
I guess I tend to use forEach, or one of the Ramada.js operations, rather than for loops these days.EcmaScript isn’t Scheme, or Smalltalk/Self, or Ruby. But it sucks a lot less than the other language I’m allowed to use at work :-)
(I pretend that ES is mostly Ruby)