3 ms·
It is my understanding that symbols were going to be a way to have private methods. This aspect of them - the reason they were going to be introduced in the fi
by nni 11y ago
It is my understanding that symbols were going to be a way to have private methods. This aspect of them - the reason they were going to be introduced in the first place - was dropped, and so you are left with its current limited form with a much narrower use-case.
From A Rossberg (he's also the guy behind SoundScript) in a March 2014 stackoverflow post (http://stackoverflow.com/questions/21724326/why-bring-symbols-to-javascript/22280202#22280202 http://stackoverflow.com/questions/21724326/why-bring-symbol...):
"Enabling private properties ... was indeed the original motivation for introducing symbols into JavaScript. Unfortunately, however, they ended up being severely downgraded, and not private after all.
They are now known as unique symbols, and their only use is to avoid name clashes between properties....Whether that is strong enough a motivation to add symbols to the language is debatable."
and from R. Waldron as part of this response (https://esdiscuss.org/topic/proposal-about-private-symbol https://esdiscuss.org/topic/proposal-about-private-symbol) to a proposal about a private symbol (Dec 2014)
"Ultimately it was decided that Symbol is just a symbol and that "private" things will be dealt with orthogonally (and at a later date)."
YMMV
- braythwayt 11y agoYou can still use them to make almost-completely-private methods and properties, it's just the syntactic sugar that was dropped: http://raganwald.com/2015/06/04/classes-are-expressions.html http://raganwald.com/2015/06/04/classes-are-expressions.html HN discussion: https://news.ycombinator.com/item?id=9660658 https://news.ycombinator.com/item?id=9660658