News for hackers. Stuff that matters.
Re:Deno Joins TC39 by mschuetz on Monday December 13, 2021 @07:40AM (#29539021)
What are your thoughts on the do expressions proposal? Cause I think they'd be awesome for cleaner scoping of temporary variables.
Re:Deno Joins TC39 by lucacasonato on Monday December 13, 2021 @07:55AM (#29539113)
I think they are great! Especially in combination with pattern matching (https://github.com/tc39/proposal-pattern-matching), or when using JSX.
Re:Deno Joins TC39 by nicoburns on Monday December 13, 2021 @08:57AM (#29539594)
Do you have any insight into how the TC39 process works, and how one might drive this work forwards? I feel like expression-orientation is the main thing missing from JavaScript at this point, and I'd love to contribute. But it's not at all clear to me how to actually do so.
Re:Deno Joins TC39 by spmurrayzzz on Monday December 13, 2021 @09:15AM (#29539729)
The TC39 process is well-documented, you can check out the stages and guidance for providing input here: https://tc39.es/process-document/

The do expression proposal is currently stage 1, so its very early. You can check out the issue tracker there to see some of the related discussion. Standards work can be deceptively hard, even for simple things. I think the do expression proposal is a good example of that.

Edit: forgot to link to the issue tracker I referenced above https://github.com/tc39/proposal-do-expressions/issues

Re:Deno Joins TC39 by benmccann on Monday December 13, 2021 @01:00PM (#29542235)
Do you have a link to the proposal?
Re:Deno Joins TC39 by mschuetz on Monday December 13, 2021 @01:03PM (#29542289)
https://github.com/tc39/proposal-do-expressions

Allows you to contain temporary variables to where they are needed, rather than having them remain active through the remainder of the current scope. You could do that with immediately invoked function expressions, but they are too verbose to be really viable for this. You could also use extra functions, but extra functions don't always make sense. Currently I'm frequently doing this:

Without do expression:

    let result;
    {
        let tmp = 123;

        result = tmp * 2;
    }

With do expression it would become this:

    let result = do {
        let tmp = 123;
     
        tmp * 2;
    }