News for hackers. Stuff that matters.
Re:JavaScript Isn't Scheme (2013) by mst on Wednesday April 25, 2018 @04:48PM (#16925970)
Promises and generators are both awesome, but they're both way more restrictive than call/cc. Now, I tend to the idea that that's usually a feature - and that at most strictly delimited continuations is more than sufficient in a normal language - but equating promises to continuations is ... not really accurate.

(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)

Re:JavaScript Isn't Scheme (2013) by rachitnigam on Wednesday April 25, 2018 @06:13PM (#16926781)
Both promises and generators can be used to implement delimited continuations.

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.

Re:JavaScript Isn't Scheme (2013) by mst on Wednesday April 25, 2018 @08:44PM (#16927872)
I've implemented delimited continuations using both. But I don't disagree with any of your factual statements.
Re:JavaScript Isn't Scheme (2013) by dahart on Wednesday April 25, 2018 @04:55PM (#16926051)
> equating promises to continuations is ... not really accurate.

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?

Re:JavaScript Isn't Scheme (2013) by Roboprog on Wednesday April 25, 2018 @05:37PM (#16926432)
Re: “let”

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)

Re:JavaScript Isn't Scheme (2013) by mst on Wednesday April 25, 2018 @08:47PM (#16927890)
Being able to write:

    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)
Re:JavaScript Isn't Scheme (2013) by Roboprog on Friday April 27, 2018 @05:39PM (#16944585)
Oh. I guess I don’t use for...in much (at all). I see your point now, though.

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)

Re:JavaScript Isn't Scheme (2013) by z3t4 on Wednesday April 25, 2018 @06:15PM (#16926793)
I like the function scope as it encourages you to create functions. functions are great! Only time it gets confusing is in the for-loop where most people expect a closure. I tell them to just put the innards of the for-loop in a function. Also with function scope you don't have to worry about the blocks, you can declare variables everywhere and they'll be hoisted.