News for hackers. Stuff that matters.
Re:ES6 in Depth: Symbols (2015) by masklinn on Thursday July 13, 2017 @03:57AM (#14759521)
> Hopefully there will still be useful cases for them.

There are already useful cases for them:

* non-conflicting extensions to existing prototypes, in fact most of the standard uses of symbol are exactly that, it finally allows the standard to add new methods to existing types (Object, String, Regex, …) without breaking everything and risking conflict with existing extensions

* similarly non-conflicting properties to non-prototype third-party objects for e.g. decorators and proxies and the like (sometimes you can't avoid bundling your data as part of the original payload)

* much like (gensym) though somewhat less convenient, can be used to avoid conflicts when doing codegen

* more convenient/debuggable sentinel object than e.g. `{}` which would tell you very little when you unwittingly leaked it, especially as symbols may be the only builtin object which is not implicitly convertible to a string

Re:ES6 in Depth: Symbols (2015) by SCdF on Thursday July 13, 2017 @07:25AM (#14760385)
Thanks for this list, very interesting!

I haven't really dealt with this level of JS before, so unfortunately I'm ignorant of every one of your bullet points. Good to see it's got lots of uses though.

Re:ES6 in Depth: Symbols (2015) by masklinn on Thursday July 13, 2017 @08:05AM (#14760578)
> I haven't really dealt with this level of JS before, so unfortunately I'm ignorant of every one of your bullet points.

That's not necessarily a bad thing, #1 is mostly of interest to the standard committee and historically considered a bad move (and in fact the source of the issue) for third parties (you may have to use its result if you want to e.g. make one of your objects iterable though), #2 is something you do when all options are exhausted, #3 is when you write your own codegen.

#4 is probably the one you're most likely to encounter, it's not that common either, and `null` or `undefined` generally work as sentinels so…

Re:ES6 in Depth: Symbols (2015) by SCdF on Thursday July 13, 2017 @08:15AM (#14760624)
Oh sure, yeah I see how #4 would be useful. Generally I've used / seen `undefined` used for that in the past, which can be problematic because it might mean what you think it means, or it might mean something broken in your algo by mistake.