The v8-users mailing list is not the best place to discuss the design of new ECMAScript language features. This proposal reached Stage 3 of the TC39 process <https://tc39.github.io/process-document/> a long time ago, and each design decision has since been revisited and reaffirmed during TC39 meetings. It’s time to ship it.
On Thu, Feb 21, 2019 at 1:07 PM J Decker <d3c...@gmail.com> wrote: > class xyz { > x = isTrueFalse(); > #y = !x; > } > > that would work in a class though? > The `x` in `#y = !x` would refer to the global `x` in this example. You probably meant to refer to the `x` field above, which you can accomplish with `#y = !this.x`. > >> On Wed, Feb 20, 2019 at 5:14 PM Adam Klein <ad...@chromium.org> wrote: >> >>> LGTM!! >>> >>> On Wed, Feb 20, 2019 at 12:20 PM 'Mathias Bynens' via blink-dev < >>> blink-...@chromium.org> wrote: >>> >>>> LGTM >>>> >>>> On Wed, Feb 20, 2019 at 8:58 PM Sathya Gunasekaran < >>>> gsat...@chromium.org> wrote: >>>> >>>>> Contact Emails >>>>> >>>>> gsat...@chromium.org >>>>> >>>>> >>>>> Spec >>>>> >>>>> https://github.com/tc39/proposal-class-fields >>>>> >>>>> >>>>> Summary (taken from our WebFu article >>>>> <https://developers.google.com/web/updates/2018/12/class-fields>) >>>>> >>>>> >>>>> >>>>> This private fields proposal provides encapsulation: If you're using >>>>> an instance of a class, you cannot reference that class's private fields >>>>> from outside the class body. You can only reference private fields from >>>>> within the class that defines them. >>>>> >>>>> >>>>> The new private fields syntax is similar to public fields, except you >>>>> mark the field as being private by using # >>>>> <https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md>. >>>>> You can think of the # as being part of the field name: >>>>> >>>>> >>>>> class IncreasingCounter { >>>>> >>>>> #count = 0; >>>>> >>>>> get value() { >>>>> >>>>> console.log('Getting the current value!'); >>>>> >>>>> return this.#count; >>>>> >>>>> } >>>>> >>>>> increment() { >>>>> >>>>> this.#count++; >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> Private fields are not accessible outside of the class body: >>>>> >>>>> >>>>> const counter = new IncreasingCounter(); >>>>> >>>>> counter.#count; >>>>> >>>>> // → SyntaxError >>>>> >>>>> counter.#count = 42; >>>>> >>>>> // → SyntaxError >>>>> >>>>> >>>>> This intent to ship includes private static fields as well: >>>>> >>>>> >>>>> class ClassCounter { >>>>> >>>>> static #count = 0; >>>>> >>>>> static increment() { >>>>> >>>>> this.#count++; >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> ClassCounter.#count; >>>>> >>>>> // → SyntaxError >>>>> >>>>> ClassCounter.increment(); >>>>> >>>>> >>>>> >>>>> Interoperability and compatibility risk >>>>> >>>>> This stage 3 proposal introduces new syntax that was previously a >>>>> SyntaxError. There’s very low web compat risk. >>>>> >>>>> >>>>> Firefox: In development >>>>> <https://bugzilla.mozilla.org/show_bug.cgi?id=1499448> >>>>> >>>>> Safari: In development >>>>> <https://bugs.webkit.org/show_bug.cgi?id=174212> >>>>> >>>>> Edge: No signals >>>>> >>>>> >>>>> Is this feature fully tested? >>>>> >>>>> >>>>> >>>>> Yes, this feature passes V8’s own mjsunit/cctest tests as well as all >>>>> the Test262 tests. >>>>> >>>>> >>>>> Tracking bug >>>>> >>>>> v8:5368 <http://bugs.chromium.org/p/v8/issues/detail?id=5368> >>>>> >>>>> >>>>> >>>>> Link to entry on the Chrome Platform Status dashboard >>>>> >>>>> https://www.chromestatus.com/feature/6035156464828416 >>>>> >>>>> >>>>> >>>>> Requesting approval to ship? >>>>> >>>>> Yes. Note that since this is a V8/JS feature, this post is just an FYI >>>>> to blink-dev — no sign off from Blink API owners is required. >>>>> >>>>> >>>>> >>>>> -- >>>>> -- >>>>> v8-dev mailing list >>>>> v8-...@googlegroups.com >>>>> http://groups.google.com/group/v8-dev >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "v8-dev" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to v8-dev+unsubscr...@googlegroups.com. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "blink-dev" group. >>>> To view this discussion on the web visit >>>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADizRgaQiv2%3DmEtPOcprwkGg_KcxCfF7A%3DpPp6q-kCW%3DGN2Mtw%40mail.gmail.com >>>> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CADizRgaQiv2%3DmEtPOcprwkGg_KcxCfF7A%3DpPp6q-kCW%3DGN2Mtw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> -- >>> v8-users mailing list >>> v8-users@googlegroups.com >>> http://groups.google.com/group/v8-users >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "v8-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to v8-users+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.