samuelgoto / proposal-block-params

A syntactical simplification in JS to enable DSLs
204 stars 8 forks source link

Syntax Questions #15

Open rwaldron opened 6 years ago

rwaldron commented 6 years ago
  1. What does this mean:
    a 
    {}
  2. What does this mean:
    a()
    {}
leobalter commented 6 years ago

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

samuelgoto commented 6 years ago

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?

leobalter commented 6 years ago

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)

samuelgoto commented 6 years ago

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 notifications@github.com 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 !

rwaldron commented 6 years ago

@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.

samuelgoto commented 6 years ago

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!