ecma262 icon indicating copy to clipboard operation
ecma262 copied to clipboard

[Stage 3 Draft] - Symbols as WeakMap keys

Open acutmore opened this issue 3 years ago • 9 comments

⚠ PR acting as preview only ⚠

rendered preview here

This PR represents the Stage 3 specification text for Symbols as WeakMap keys.

The proposed spec has been written as a PR against the full spec due to the high number of small tweaks to descriptions and notes in sections such as liveness.

A separate minimal proposal specification with only the core changes is available at http://tc39.es/proposal-symbols-as-weakmap-keys

acutmore avatar May 17 '22 14:05 acutmore

I'm getting a 403 error when it tries to upload the preview: https://github.com/tc39/ecma262/runs/6472329978?check_suite_focus=true

Is there something I need to do?

acutmore avatar May 17 '22 14:05 acutmore

@acutmore i'll take a look at it when i have a moment.

ljharb avatar May 17 '22 16:05 ljharb

@acutmore i'll take a look at it when i have a moment.

The generated preview seems to have sorted itself out now - thanks anyway!

acutmore avatar May 18 '22 12:05 acutmore

1 week till plenary. If reviewers could take a look at the latest draft this week that would be great. Thanks! If happy with proposed text then we can check off on the tracking issue https://github.com/tc39/proposal-symbols-as-weakmap-keys/issues/17

cc: @brad4d @ljharb @mhofman @gibson042

acutmore avatar May 30 '22 13:05 acutmore

Before this lands, I think 402 will need to be updated so the IntlFallbackSymbol is appended to the well-known symbols table (such that the symbol is automatically allowed to be held weakly)

Looks good overall though!

The AO for determining if a symbol can be held weakly is done by exclusion, so IntlFallbackSymbol will be allowed implicitly. It would only be disallowed if an implementation had incorrectly implemented it using Symbol.for, which does not appear to be the case for the implementations I've checked.

https://github.com/v8/v8/blob/5fe0aa3bc79c0a9d3ad546b79211f07105f09585/src/init/heap-symbols.h#L457

https://searchfox.org/mozilla-central/rev/3419858c997f422e3e70020a46baae7f0ec6dacc/js/src/builtin/intl/CommonFunctions.js#735

https://github.com/WebKit/WebKit/blob/84cfeb18efa90b3f67962f66c701f753633c618a/Source/JavaScriptCore/builtins/BuiltinNames.cpp#L44

acutmore avatar Jun 01 '22 11:06 acutmore

@acutmore thats a good callout, but a cross-realm, non-registry symbol still belongs in that table, and imo it’s an editorial error in 402 that it does not.

ljharb avatar Jun 01 '22 14:06 ljharb

@acutmore thats a good callout, but a cross-realm, non-registry symbol still belongs in that table, and imo it’s an editorial error in 402 that it does not.

I don't believe it's an error. The fallback symbol is not meant to be cross-realm, 402 says explicitly it isn't. However there is no impact[^*] to this proposal since in both cases it could be held weakly.

[^*]: In practice, making Intl unreachable in the current realm would potentially make the symbol to itself become unreachable, which could be observed through WeakRef / FinalizationRegistry if implementations did the work to collect these intrinsics.

mhofman avatar Jun 07 '22 05:06 mhofman

To capture @erights's comment during the presentation, we would like to have well-known symbols be normatively described as an invariant along the lines of:

The string properties of the global %Symbol% that have a value with a symbol type.

Let me know if you want me to open a dedicated issue for this.

mhofman avatar Jun 07 '22 16:06 mhofman

To capture @erights's comment during the presentation, we would like to have well-known symbols be normatively described as an invariant along the lines of:

The string properties of the global %Symbol% that have a value with a symbol type.

Let me know if you want me to open a dedicated issue for this.

Opening an issue on the ecma262 repo sounds like the best place to capture that.

acutmore avatar Jun 08 '22 15:06 acutmore

This proposal has test262 tests now.

ptomato avatar Jan 03 '23 20:01 ptomato

@acutmore it may be time to rebase this :-)

ljharb avatar Jan 03 '23 20:01 ljharb

This proposal is now stage 4: https://github.com/tc39/proposals/commit/d2a5cf370e4a9dc8b0249ad8a8386cd1280db815

acutmore avatar Feb 06 '23 11:02 acutmore

@acutmore: This PR has merge conflicts (from PR #2947, it looks like). If you resolve those, I can take another look.

jmdyck avatar Feb 25 '23 15:02 jmdyck

@michaelficarra and I have chatted about our disagreement of the use of "identity" for the concept of "can be used as a weak target", and we're agreed on stratifying the concept of identity into "specification identity" and "language identity", with "language identity" being the concept that this proposal should use.

This PR should block on https://github.com/tc39/ecma262/pull/3027 which does the stratification.

syg avatar Mar 09 '23 00:03 syg