Kevin Gibbons

Results 638 comments of Kevin Gibbons

Because in statement contexts - which would include the body of a `do` - `{` begins a block, not an object literal.

Function and class declarations are the other example; you can't have either as the final statement of a `do`, since that would not have the semantics you'd expect. That particular...

> Is it because the inner `do` looks like a `do..while` loop (statement)? [Yup](https://github.com/tc39/proposal-do-expressions#conflict-with-do-while). That said, there's not much use for a `do` expression in statement position, since `(do {...

> In the case of "returning" a function expression by wrapping it in parens, that even less "looks like" a return because devs have for so many years been conditioned...

> Await is forgiving, and you can await a non-promise, which is just a synchronous pass-through operation, right? No. You can await a non-promise, but it does entail a microtask...

That example is just to illustrate that `await` causes a microtask tick even if the value being `await`'d is not a Promise.

I don't want to focus too much on the microtask ticks here. For me the main reason not to use an IIFE here is that it's much harder for a...

> couldn't your most recent example be rewritten without the do in the first place? Yeah, I was just following an example introduced earlier. The cases where you'd actually want...

@yuchi, off topic, but > ```js > function MagicList(props) { > return ( > > {do for (let incantation of props.incantations) { > ({incantation.name}); > }} > > ); >...

I don't think this really makes sense with how the rest of the language works. The idea is that `do` is a very simple wrapper for statements which you could...