Re: Make comma at the end of line optional (Naveen Chawla)
On Wed, Sep 13, 2017 at 3:52 PM, Aluan Haddadwrote: > > ...given the countless hours already wasted debating semicolon > usage, and with the inherent complexity that this would add to > tools like transpilers and minifiers, this would seem to add > negative value. ^^ this. I've been trying to phrase it for a while now. Well put. It's useful to remember that JavaScript engines are not the only consumers of JavaScript source code. Linters, transpilers, syntax highlighters, code introspection and refactoring tools, etc., etc., etc. -- they all have their cages rattled by syntax changes. The more complex the syntax (and this would have to be quite complex in a world of class fields, private data, etc.), the more the cages are rattled. Humans, too, are consumers of JavaScript source code. We're clever, but adding to the cognitive load needs a good justification. For me, the cost/benefit on this optional commas thing is just nowhere near a sell. -- T.J. Crowder ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Make comma at the end of line optional (Naveen Chawla)
I can see an argument for this by analogy with class syntax but I for one would immediately go looking for a linter which raised errors for these omitted commas. Furthermore, given the countless hours already wasted debating semicolon usage, and with the inherent complexity that this would add to tools like transpilers and minifiers, this would seem to add negative value. On Sep 13, 2017 10:32 AM, <es-discuss-requ...@mozilla.org> wrote: > Send es-discuss mailing list submissions to > es-discuss@mozilla.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.mozilla.org/listinfo/es-discuss > or, via email, send a message with subject or body 'help' to > es-discuss-requ...@mozilla.org > > You can reach the person managing the list at > es-discuss-ow...@mozilla.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of es-discuss digest..." > > Today's Topics: > >1. Re: Make comma at the end of line optional (Naveen Chawla) >2. Re: Lazy evaluation (Andrea Giammarchi) > > > -- Forwarded message -- > From: Naveen Chawla <naveen.c...@gmail.com> > To: Boris Zbarsky <bzbar...@mit.edu>, es-discuss@mozilla.org > Cc: > Bcc: > Date: Wed, 13 Sep 2017 13:57:01 + > Subject: Re: Make comma at the end of line optional > I'm not really familiar with ASI but they key factor mentioned in this > discussion is this (by Claude Pache): > > *A implicit semicolon is not added when a declaration would be complete, > but when the next token would produce a syntax error. * > > By this behaviour (a modification to the initial "complete statement > produces comma" version of this proposal), everything would work perfectly, > no? > > The multi-line get would not produce a comma, and hence the scheme is > backwards compatible, right? > > Please provide a counter-example if I have missed something. > > As for the benefit, the time savings in not having to debug accidentally > omitted commas and not having to add them in the first place are, I think, > an improvement. And of course those who want to continue using commas > everywhere, can: > > ```js > function doStuff( > x > y > z > ){ > } > ``` > > ``` > const >x = 5 >y = 6 >z = 7 > ``` > > Great to hear those counter-examples as I don't know enough about ASI, and > the related subject, to picture the pitfalls (sorry for my ignorance on > this). Also it would be good for reference on this proposal... > > On Wed, 13 Sep 2017 at 18:40 Boris Zbarsky <bzbar...@mit.edu> wrote: > >> On 9/13/17 9:05 AM, Naveen Chawla wrote: >> > Can someone remind me of the problem doing it this way, if any? >> >> You mean apart from all the existing footguns ASI has? >> >> -Boris >> ___ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > > > -- Forwarded message -- > From: Andrea Giammarchi <andrea.giammar...@gmail.com> > To: Alex Kodat <alexko...@gmail.com> > Cc: "es-discuss@mozilla.org" <es-discuss@mozilla.org> > Bcc: > Date: Wed, 13 Sep 2017 16:32:28 +0200 > Subject: Re: Lazy evaluation > > Maybe you mean "will behave more or less as if (except more > efficiently)"? > > no, I meant: it will transpiled into something using private WeakMaps. > > I don't have any interest in talk nanoseconds for something unrelated to > the topic though. > > Best Regards > > On Wed, Sep 13, 2017 at 1:54 PM, Alex Kodat <alexko...@gmail.com> wrote: > >> What do you mean by “will be transpiled through”? My understanding of the >> private property proposal is that private properties will be in fixed slots >> (inaccessible outside the class) in the object so there would be no >> WeakMap. Maybe you mean "will behave more or less as if (except more >> efficiently)"? >> >> >> Alex Kodat >> >> From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of >> Andrea Giammarchi >> Sent: Wednesday, September 13, 2017 2:31 AM >> To: Steve Fink <sph...@gmail.com> >> Cc: es-discuss@mozilla.org >> Subject: Re: Lazy evaluation >> >> > The properties already existed, so defineProperty shouldn't modify the >> order IIUC >> >> well, nope. the property existed in the prototype, not in the object. >> >> anyway, I guess private properties, that are a possible solution, will be >>
Re: Make comma at the end of line optional (Naveen Chawla)
I can see the argument for this by analogy with class syntax but On Sep 13, 2017 10:32 AM, <es-discuss-requ...@mozilla.org> wrote: Send es-discuss mailing list submissions to es-discuss@mozilla.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.mozilla.org/listinfo/es-discuss or, via email, send a message with subject or body 'help' to es-discuss-requ...@mozilla.org You can reach the person managing the list at es-discuss-ow...@mozilla.org When replying, please edit your Subject line so it is more specific than "Re: Contents of es-discuss digest..." Today's Topics: 1. Re: Make comma at the end of line optional (Naveen Chawla) 2. Re: Lazy evaluation (Andrea Giammarchi) -- Forwarded message -- From: Naveen Chawla <naveen.c...@gmail.com> To: Boris Zbarsky <bzbar...@mit.edu>, es-discuss@mozilla.org Cc: Bcc: Date: Wed, 13 Sep 2017 13:57:01 + Subject: Re: Make comma at the end of line optional I'm not really familiar with ASI but they key factor mentioned in this discussion is this (by Claude Pache): *A implicit semicolon is not added when a declaration would be complete, but when the next token would produce a syntax error. * By this behaviour (a modification to the initial "complete statement produces comma" version of this proposal), everything would work perfectly, no? The multi-line get would not produce a comma, and hence the scheme is backwards compatible, right? Please provide a counter-example if I have missed something. As for the benefit, the time savings in not having to debug accidentally omitted commas and not having to add them in the first place are, I think, an improvement. And of course those who want to continue using commas everywhere, can: ```js function doStuff( x y z ){ } ``` ``` const x = 5 y = 6 z = 7 ``` Great to hear those counter-examples as I don't know enough about ASI, and the related subject, to picture the pitfalls (sorry for my ignorance on this). Also it would be good for reference on this proposal... On Wed, 13 Sep 2017 at 18:40 Boris Zbarsky <bzbar...@mit.edu> wrote: > On 9/13/17 9:05 AM, Naveen Chawla wrote: > > Can someone remind me of the problem doing it this way, if any? > > You mean apart from all the existing footguns ASI has? > > -Boris > ___ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -- Forwarded message -- From: Andrea Giammarchi <andrea.giammar...@gmail.com> To: Alex Kodat <alexko...@gmail.com> Cc: "es-discuss@mozilla.org" <es-discuss@mozilla.org> Bcc: Date: Wed, 13 Sep 2017 16:32:28 +0200 Subject: Re: Lazy evaluation > Maybe you mean "will behave more or less as if (except more efficiently)"? no, I meant: it will transpiled into something using private WeakMaps. I don't have any interest in talk nanoseconds for something unrelated to the topic though. Best Regards On Wed, Sep 13, 2017 at 1:54 PM, Alex Kodat <alexko...@gmail.com> wrote: > What do you mean by “will be transpiled through”? My understanding of the > private property proposal is that private properties will be in fixed slots > (inaccessible outside the class) in the object so there would be no > WeakMap. Maybe you mean "will behave more or less as if (except more > efficiently)"? > > > Alex Kodat > > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of > Andrea Giammarchi > Sent: Wednesday, September 13, 2017 2:31 AM > To: Steve Fink <sph...@gmail.com> > Cc: es-discuss@mozilla.org > Subject: Re: Lazy evaluation > > > The properties already existed, so defineProperty shouldn't modify the > order IIUC > > well, nope. the property existed in the prototype, not in the object. > > anyway, I guess private properties, that are a possible solution, will be > transpiled through a WeakMap so that most likely anything discussed in here > won't make sense and the future code would look like the following > > ```js > class A { > #random; > get random() { > return this.#random || > (this.#random = Math.random()); > } > } > > > // transpiled > var A = function (wm) { > function A() { > wm.set(this, {random: void 0}); > } > Object.defineProperties( > A.prototype, > { > random: { > configurable: true, > get: function () { > return wm.get(this).random || > (wm.get(this).random = Math.random()); > } > } > } > ); > return A; > }(new WeakMap); > ``` > > > > > > > On Tue, Sep 12, 2017 at 10:39 PM, Steve Fink <mailto:sph...