This refactoring hazard is intimately tied to the infinite look-ahead
problem. Teaching a parser to handle the latter case or examples like `if
(x) (y) -z {}` correctly is gonna be all but easy. Either backtracking or
terrifying grammar refactorings would be needed.On 1 February 2016 at 18:46, Brendan Eich <[email protected]> wrote: > On Mon, Feb 1, 2016 at 8:02 AM kdex <[email protected]> wrote: > >> [Douglas Crockford](https://www.youtube.com/watch?v=Nlqv6NtBXcA) and >> [Brendan Eich](https://brendaneich.com/2010/11/paren-free/) seem >> >> to be in favor of making them optional; that's why the strawman exists. >> >> > The strawman exists because I wrote it, yes. > > I was inspired by the common (not ubiquitous) style of always bracing > sub-statements. The paren-free meme did "stick" with Rust, but it seems > doomed for JS on account of the problems Waldemar Horwat raised: > > https://esdiscuss.org/topic/another-paren-free-gotcha > > Not the cited example, that seemed to forget that paren-free requires > braces around the sub-statement in absence of leading left paren after > controlling keyword. I pointed this out here: > > https://esdiscuss.org/topic/another-paren-free-gotcha#content-9 > > Waldemar's other example showed a refactoring hazard: > > """ > > if (a + b/g > f) f = a + b/g > > Convert it to paren-free: > > if a + b/g > f {f = a + b/g} > > So far so good; it works. However, later someone discovers that the code > had a logic error, the fix to which is to divide the sum a+b by c instead > of dividing only b by c. So he fixes the code to: > > if (a + b)/g > f {f = (a + b)/g} > > """ > > Anyway, the proposal predates 1JS (note my last message talks about "opt > in") and needs a champion who can resolve the refactoring hazard worry (if > possible). > > /be > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

