Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES2023: Symbol as a Key #1666

Closed
1 task
azu opened this issue May 12, 2023 · 1 comment · Fixed by #1684
Closed
1 task

ES2023: Symbol as a Key #1666

azu opened this issue May 12, 2023 · 1 comment · Fixed by #1684
Labels
Lang: ES2023 ECMAScript 2023

Comments

@azu
Copy link
Collaborator

azu commented May 12, 2023

Symbol as a Key

tc39/proposal-symbols-as-weakmap-keys: Permit Symbols as keys in WeakMaps, entries in WeakSets and WeakRefs, and registered in FinalizationRegistries

仕組み的には結構面白いことになってる。

  • Symbol()
  • Symbol.for()

に意味的な違いが結構出てる。
Symbol forはregistered symbolでこれ使うとweakが観測可能になる問題があるから、weakのkeyには使えないということか。
なので使えるのはSymbolだけ

対応的には、weakの話でキーに指定できるものへsymbolが追加されたことだけど、
キーに指定できるものを書いてはない?

また、弱い参照で値を持つ特性上、WeakSetの値として使えるのは参照型のオブジェクトだけです

Setのここだけ修正が入りそう

Originally posted by @azu in #1658 (comment)

Blocker

@azu azu added the Lang: ES2023 ECMAScript 2023 label May 12, 2023
@azu azu mentioned this issue Jun 25, 2023
9 tasks
@azu
Copy link
Collaborator Author

azu commented Jun 25, 2023

これまだFirefox対応してなさそう

const map = new WeakMap();
const s = Symbol("desc");
map.set(s, {})
map.get(s);

@azu azu changed the title ES2023 Symbol as a Key ES2023: Symbol as a Key Jul 30, 2023
@azu azu linked a pull request Aug 3, 2023 that will close this issue
@azu azu closed this as completed in #1684 Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lang: ES2023 ECMAScript 2023
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant