Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Switch to lexically declarations in classes #10

Merged
merged 5 commits into from
Jan 16, 2018
Merged

Switch to lexically declarations in classes #10

merged 5 commits into from
Jan 16, 2018

Conversation

littledan
Copy link
Member

Based on feedback in #4

README.md Outdated
Counter.count; // 1, own property
SubCounter.count; // 0, own property

// ++ is just dealing iwth own properties the whole time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: iwth -> with

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this correction. There are lots of typos here; probably better for others not to spend time looking for them until I do another pass over things.

This patch specifies lexically scoped declarations in class bodies,
with a token preceding them. Because we haven't figured out which
token to use (#9), <placeholder> is used instead. Some main design points:
- let, const, class and function (including async fns, generators) are
  supported, and var declarations are not supported.
- Function declarations are hoisted to the top of the block, before
  evaluating the extends clause.
- let, const and class declarations are evaluated interspersed with
  static public field initializers.
- The class is visible with a binding initialized when the lexical
  declarations are evaluated.
- Unlike static public field initializers which are in a scope analogous
  to a method (with super property access, and this being the class),
  the scope of lexical declarations inherits directly from the outer
  scope, similarly to computed proerty names and the extends clause,
  which implies:
    - this, super, new.target are inherited from the lexical context,
      and are not related to the current class definition.
    - arguments is not poisoned and is inherited from an outer definition
    - yield, await can be used if possible in the enclosing function.
@littledan
Copy link
Member Author

This hasn't had much time for review yet, but merging early so that more people can get a look at the proposal. Please keep the reviews coming, either in comments on this thread or bugs/PRs.

@littledan littledan merged commit 731241b into master Jan 16, 2018
@ljharb ljharb deleted the lexical branch January 24, 2022 20:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants