Symbol history

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Symbol history

T.J. Crowder-2
Hi all,

I've tried to glean this from the meeting notes and such, but many who were actively involved are on the list, so:

Am I right that Symbols started out as "private Name objects" then over time their name was changed, they became primitives, and the privacy aspect was dropped; but having guaranteed-unique values was still useful, and found application (amongst other places) in solving the problem of adding a default iterator to `Array.prototype` without name conflicts with existing code in the wild?

Thanks,

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Allen Wirfs-Brock
That's a pretty good summary

Sent from BlueMail
On May 28, 2018, at 2:09 PM, "T.J. Crowder" <[hidden email]> wrote:
Hi all,

I've tried to glean this from the meeting notes and such, but many who were actively involved are on the list, so:

Am I right that Symbols started out as "private Name objects" then over time their name was changed, they became primitives, and the privacy aspect was dropped; but having guaranteed-unique values was still useful, and found application (amongst other places) in solving the problem of adding a default iterator to `Array.prototype` without name conflicts with existing code in the wild?

Thanks,

-- T.J. Crowder


es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Michael Dyck
In reply to this post by T.J. Crowder-2
On 2018-05-28 02:09 PM, T.J. Crowder wrote:
>
> Am I right that Symbols started out as "private Name objects" then over time
> their name was changed, they became primitives,

As far as the spec is concerned...

Symbols were introduced in draft 12 of ES6.
They were defined as a kind of exotic object, stateless and immutable.

In draft 15, Symbol became a primitive type.
In draft 16, it went back to being a kind of exotic object.
In draft 19, it went back to being a primitive type.

You can find the drafts here:
http://web.archive.org/web/20131017074027/http://wiki.ecmascript.org:80/doku.php?id=harmony:specification_drafts

-Michael
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Mark Miller-2
In reply to this post by T.J. Crowder-2
There was at some point an attempt at elaborating "symbol" into some kind of "private name" or "private symbol", which failed for well explained reasons. However, this is not where symbols started. Symbols started as a way to introduce new properties while avoiding conflict with possible property names, IOW, as a way to introduce new property "names" that were guaranteed not to collide with any existing names. This is still their primary purpose.


On Mon, May 28, 2018 at 11:09 AM, T.J. Crowder <[hidden email]> wrote:
Hi all,

I've tried to glean this from the meeting notes and such, but many who were actively involved are on the list, so:

Am I right that Symbols started out as "private Name objects" then over time their name was changed, they became primitives, and the privacy aspect was dropped; but having guaranteed-unique values was still useful, and found application (amongst other places) in solving the problem of adding a default iterator to `Array.prototype` without name conflicts with existing code in the wild?

Thanks,

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
  Cheers,
  --MarkM

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Mike Samuel
https://esdiscuss.org/topic/private-slots
"""
Allen Wirfs-Brock (5 years ago)

As further evidence, the word "private" does not even occur in sections 8.1.6 and 8.1.6.1 of the current ES6 draft. These are the sections that define the ES6 object model. Small changes and additions had to be made to allow for property keys to be either strings or symbols but those changes are independent of whether a symbol is private or not. The only place that the privateness of a symbol comes into play (besides in proxies) is in the context of a few reflection operations whose behavior is predicated upon whether a symbol property key is a private symbol or not. This is very similar to the tests that the same or similar operations make on individual property attributes.
"""
I don't know when Object.getOwnPropertySymbols made symbols useless for private-like symbols, bit IIUC, 5 years ago they were kind of being advanced for both to allow properties visible only to a symbol holder and for cooperative namespace separation.



On Mon, May 28, 2018 at 3:48 PM, Mark Miller <[hidden email]> wrote:
There was at some point an attempt at elaborating "symbol" into some kind of "private name" or "private symbol", which failed for well explained reasons. However, this is not where symbols started. Symbols started as a way to introduce new properties while avoiding conflict with possible property names, IOW, as a way to introduce new property "names" that were guaranteed not to collide with any existing names. This is still their primary purpose.


On Mon, May 28, 2018 at 11:09 AM, T.J. Crowder <[hidden email]> wrote:
Hi all,

I've tried to glean this from the meeting notes and such, but many who were actively involved are on the list, so:

Am I right that Symbols started out as "private Name objects" then over time their name was changed, they became primitives, and the privacy aspect was dropped; but having guaranteed-unique values was still useful, and found application (amongst other places) in solving the problem of adding a default iterator to `Array.prototype` without name conflicts with existing code in the wild?

Thanks,

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
  Cheers,
  --MarkM

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Allen Wirfs-Brock
For a while TC39 considered syntactic support for referencing Symbol-keyed properties. EG:

let pri = new Symbol;
obj.@pri = 42;

When we realized that symbols weren't private enough, we decided that [ ] would suffice.

At that point using Symbols for "soft private" was no more convenient and perhaps  less then just using a _ prefix to be indicate soft-private.
On May 28, 2018, at 4:10 PM, Mike Samuel <[hidden email]> wrote:
https://esdiscuss.org/topic/private-slots
"""
Allen Wirfs-Brock (5 years ago)

As further evidence, the word "private" does not even occur in sections 8.1.6 and 8.1.6.1 of the current ES6 draft. These are the sections that define the ES6 object model. Small changes and additions had to be made to allow for property keys to be either strings or symbols but those changes are independent of whether a symbol is private or not. The only place that the privateness of a symbol comes into play (besides in proxies) is in the context of a few reflection operations whose behavior is predicated upon whether a symbol property key is a private symbol or not. This is very similar to the tests that the same or similar operations make on individual property attributes.
"""
I don't know when Object.getOwnPropertySymbols made symbols useless for private-like symbols, bit IIUC, 5 years ago they were kind of being advanced for both to allow properties visible only to a symbol holder and for cooperative namespace separation.



On Mon, May 28, 2018 at 3:48 PM, Mark Miller <[hidden email]> wrote:
There was at some point an attempt at elaborating "symbol" into some kind of "private name" or "private symbol", which failed for well explained reasons. However, this is not where symbols started. Symbols started as a way to introduce new properties while avoiding conflict with possible property names, IOW, as a way to introduce new property "names" that were guaranteed not to collide with any existing names. This is still their primary purpose.


On Mon, May 28, 2018 at 11:09 AM, T.J. Crowder <[hidden email]> wrote:
Hi all,

I've tried to glean this from the meeting notes and such, but many who were actively involved are on the list, so:

Am I right that Symbols started out as "private Name objects" then over time their name was changed, they became primitives, and the privacy aspect was dropped; but having guaranteed-unique values was still useful, and found application (amongst other places) in solving the problem of adding a default iterator to `Array.prototype` without name conflicts with existing code in the wild?

Thanks,

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
  Cheers,
  --MarkM

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

Allen Wirfs-Brock
A good starting point for researching the history is:
And the pages it links to.


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

T.J. Crowder-2
Thanks all!

On Mon, May 28, 2018 at 7:36 PM, Michael Dyck <[hidden email]> wrote:
> As far as the spec is concerned...

Thanks. Sorry Michael, I should have been more clear: I'm talking about the history _leading up_ to the spec.

On Mon, May 28, 2018 at 7:33 PM, Allen Wirfs-Brock <[hidden email]> wrote:
> That's a pretty good summary

On Tue, May 29, 2018 at 2:51 AM, Allen Wirfs-Brock <[hidden email]> wrote:
> A good starting point for researching the history is:
> https://web.archive.org/web/20110505015255/http://wiki.ecmascript.org:80/doku.php?id=strawman:private_names

Thanks Allen. If the summary was good enough, that's as much detail as I need to get into.

Thanks again all!

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Symbol history

kai zhu
As far as the spec is concerned...

Symbols were introduced in draft 12 of ES6.
They were defined as a kind of exotic object, stateless and immutable.

In draft 15, Symbol became a primitive type.
In draft 16, it went back to being a kind of exotic object.
In draft 19, it went back to being a primitive type.

can i ask why they were changed to primitive-type instead of exotic-object? what are the disadvantages of keeping symbols as objects (with an extra Object.isSymbol subtype-check)?

because one obvious advantage from what i see, is to avoid breaking backwards-compatibility with previously stable-code (since es1 in 1997 [1]) that rely on typeof checks:

```js
if (typeof foo === ...) {
    ...
} else {
    // break backwards-compatibility with stable-code since es1
    // due to unexpected symbol-case
    ...
}
```

[1] ECMA-262, 1st edition, June 1997
<a href="https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262, 1st edition, June 1997.pdf" class="">https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf


On 29 May 2018, at 3:33 PM, T.J. Crowder <[hidden email]> wrote:

Thanks all!

On Mon, May 28, 2018 at 7:36 PM, Michael Dyck <[hidden email]> wrote:
> As far as the spec is concerned...

Thanks. Sorry Michael, I should have been more clear: I'm talking about the history _leading up_ to the spec.

On Mon, May 28, 2018 at 7:33 PM, Allen Wirfs-Brock <[hidden email]> wrote:
> That's a pretty good summary

On Tue, May 29, 2018 at 2:51 AM, Allen Wirfs-Brock <[hidden email]> wrote:
> A good starting point for researching the history is:
> https://web.archive.org/web/20110505015255/http://wiki.ecmascript.org:80/doku.php?id=strawman:private_names

Thanks Allen. If the summary was good enough, that's as much detail as I need to get into.

Thanks again all!

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss