(Almost) everything is expression

Mike Samuel mikesamuel at gmail.com
Fri Nov 11 14:51:02 PST 2011

2011/11/11 David Herman <dherman at mozilla.com>:
> On Nov 11, 2011, at 3:48 AM, François REMY wrote:
>> I think you strongly underestimate the "distinction" problem. ... It's completelty unclear to me. If there's no way to tell what the "return statement" of the block is, there's no way to implement your proposal.
> It's actually quite easy to implement Dmitry's proposal, because it's already specified by the ECMAScript semantics! All statements can produce completion values. You can test this yourself: take any statement, quote it as a string, and put it in eval, and you'll get a value (if it doesn't loop infinitely, exit the program, or throw an exception, of course).

If statements as expressions goes forward, we should look into
tweaking completion values.

IMHO, a code maintainer who sees

    resource = ..., foo(resource)

would expect to be able to wrap the use of resource in a try finally thus

    resource = ..., (try { foo(resource) } finally { release(resource) })

without changing the completion value of the expression.

More information about the es-discuss mailing list