On Thu, Jan 18, 2018 at 12:21 PM, Michael Rosefield <[email protected]>
wrote:
>
> Just to stick my uninformed oar into this, I notice what
> `do-while` statements *already* return a value in the exact way
> as the proposal.

FYI, it's not just `do-while`: Any statement (including the block
statement) "returns" the value of the last expression evaluated within it.
But as you indicated, that's only available to the JavaScript engine itself
(and REPLs that integrate with it).

The purpose of `do` is to expose that to code. I'm sure Dave Herman looked
at the ramifications of allowing statements as expressions in the general
case and found issues (I'd be shocked if there weren't really quite major
issues with doing that). Separately, without the leading `do` there's no
way, syntactically, to use a block statement as the do expression (since in
an expression context, the `{` meant to introduce the block parses as the
beginning of an object initializer).

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to