domenic / proposal-blocks

Former home of a proposal for a new syntactic construct for serializable blocks of JavaScript code
215 stars 5 forks source link

Block or function scope? #8

Closed jakearchibald closed 6 years ago

jakearchibald commented 6 years ago
await worker({|
  var foo = 'bar';
|});

Does the above create a variable scoped to the block, or a syntax error?

TejasQ commented 6 years ago

As a would-be user of this syntax, I'd expect a syntax error here.

domenic commented 6 years ago

Per the last paragraph of https://github.com/domenic/proposal-blocks#the-basic-idea, it creates a variable scoped to the block/function body.

jakearchibald commented 6 years ago

Ah, sorry, missed that bit.

I think this is another reason a function-like syntax would be clearer https://github.com/domenic/proposal-blocks/issues/5.