proposal-block-params icon indicating copy to clipboard operation
proposal-block-params copied to clipboard

Syntax Questions

Open rwaldron opened this issue 8 years ago • 6 comments

  1. What does this mean:
a 
{}
  1. What does this mean:
a()
{}

rwaldron avatar Nov 09 '17 17:11 rwaldron

a NoLineTerminator is certainly required to avoid breaking a matching LHSExpressoin + a Block

leobalter avatar Nov 09 '17 19:11 leobalter

Right, this came up while running this by @waldemarhorwat. In the current formulation, as @leobalter said, these two things would mean different things.

a 
{}

Are two statements, one with a as an identifier and the second as an object literal {}.

On (2), the same thinking applies:

a()
{}

It means a method call a() and an object literal {}.

Does that make sense?

samuelgoto avatar Nov 09 '17 19:11 samuelgoto

Are two statements, one with a as an identifier and the second as an object literal {}.

it's not an object literal, it's a Block. ASI needs to prevail as both are valid code already.

var a = 42;
a
{}

The completion value should be 42 (getting a)

leobalter avatar Nov 09 '17 19:11 leobalter

Ah, fair, yes, a block. Still, point being that this is NOT equivalent to a(function {}).

Makes sense?

On Thu, Nov 9, 2017 at 11:35 AM, Leo Balter [email protected] wrote:

Are two statements, one with a as an identifier and the second as an object literal {}.

it's not an object literal, it's a Block https://tc39.github.io/ecma262/#prod-Block. ASI needs to prevail as both are valid code already.

var a = 42; a {}

The completion value should be 42 (getting a)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/samuelgoto/proposal-block-params/issues/15#issuecomment-343266873, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqV6phmD7pt-Q837RDvWRp7Jc8o7i0Rks5s01PsgaJpZM4QYYaL .

-- f u cn rd ths u cn b a gd prgmr !

samuelgoto avatar Nov 09 '17 19:11 samuelgoto

@samuelgoto

Does that make sense?

Mostly, but @leobalter already pointed out the important corrections.

Still, point being that this is NOT equivalent to a(function {}).

That's what I was hoping to verify. This issue can be closed once a valid grammar exists which satisfies the requirement, ideally @leobalter's recommendation.

rwaldron avatar Nov 09 '17 19:11 rwaldron

a NoLineTerminator is certainly required to avoid breaking a matching LHSExpressoin + a Block

@leobalter 's recommendation works for me. I'm going to keep this open just to make sure we don't forget this when writing a more specific spec (the text right now is very informal).

good catch, thanks!

samuelgoto avatar Nov 10 '17 00:11 samuelgoto