tc39 / proposal-static-class-features

The static parts of new class features, in a separate proposal
https://arai-a.github.io/ecma262-compare/?pr=1668
127 stars 27 forks source link

Impressions from the January 2018 TC39 meeting and next steps #25

Closed littledan closed 6 years ago

littledan commented 6 years ago

In the January 2018 TC39 meeting, I presented the version of this proposal which is based on static public fields and lexically scoped hoistable declarations in class bodies (slides, notes). This issue summarizes my understanding of the feedback, both in and around the meeting, and a possible direction for next steps.

Static public fields

Lexical declarations in class bodies

Bigger picture feedback

Generally, I heard a lot more feedback about things that we shouldn't do rather than that we must do things. Static public fields, and some kind of function or method which can access private instance fields, are widely shared goals. At the same time, a number of people cautioned against introducing excessive complexity into the language.

Different groups of committee members have expressed wanting to go in a direction either based on static private or lexical scoping, each group with intuition that they are the most intuitive and general programming models for JavaScript. We've also advanced in thinking through proposals for private name declarations outside of classes (e.g., @rauschma) and static blocks in classes (e.g., @rbuckton), additional ways to get at some of the same problem space.

Luckily, at this point, we have looked into several alternatives in detail, discussed various intuitions committee members have about their syntax and edge cases, and are further along in developing them than we were a few months ago. Documentation of their details can be found in various places, scattered around this repository.

Next steps

I'm thinking of proposing static public fields for re-promotion to Stage 3 and helping others pursue other class features in follow-on, separate staged proposals.

Why static public fields are ready

One thing that we've learned through the process of examining several alternative proposals in detail is that none of them have an unresolvable conflict with the semantics of static public fields. We've also not yet come across feasible alternative semantics for static public fields.

TC39 demoted static public fields to Stage 2 together with static private class features in order to make sure that we thoroughly consider alternatives and don't advance things in a way that is not well thought through or prematurely cuts off reasonable follow-on proposals. I think we've done our requested homework.

Developing follow-on proposals

This repository currently contains a lot of information about various follow-on proposals already, though it's voiced in a frame of "this is selected over the others for the following reason". I don't see entirely fatal flaws in any of them, but rather tradeoffs that we could decide to make one way or another (but whose decision will not make us regret the static public fields design).

The next step here would be to write explainers for these follow-on proposals and bring them to committee. Could we identify champions for each of these proposals to write this document? I'm happy to help out champions however I can.

  1. Static private (champion?)
  2. Lexically scoped declarations in class bodies (champion?)
  3. Private names declared outside of class bodies (champion?)
  4. Static blocks (champion?)