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

Symbol VS string for the fantasy-land property #1

Open
rpominov opened this issue Nov 27, 2016 · 4 comments
Open

Symbol VS string for the fantasy-land property #1

rpominov opened this issue Nov 27, 2016 · 4 comments

Comments

@rpominov
Copy link
Member

This was discussed when we made methods on prototype prefixed. And overall impression was that symbols don't add any value compared to just unique enough strings. See fantasyland/fantasy-land#146

I think we should revisit this. Although I personally still don't see any advantages of symbols, it might be the case that we just missing something.

@rpominov rpominov changed the title Symbol VS string for fantasy-land the property Symbol VS string for the fantasy-land property Nov 28, 2016
@lin7sh
Copy link

lin7sh commented Nov 28, 2016

I'm up for Symbol. I don't know the implementation detail of Symbol, but using Symbol conforms the the use case for FL, for me obj[fl.map] is very like obj[Symbol.iterator] which is the convention for ES6. So besides of the potential performance advantage of using Symbol(I don't really know if there is), it feels nature for the normal JS programmer(like me) who knows the convention to use Symbol.

@davidchambers
Copy link
Member

I've yet to have anyone explain to me a single benefit of symbols given that they are defined in a global registry and thus share a namespace (just as strings do, really).

@rpominov
Copy link
Member Author

rpominov commented Nov 28, 2016

Ok to play a devil's advocate a bit, here a couple minor benefits of Symbols:

  • Even though they also live in a shared global namespace, this namespace is much less occupied, so in this namespace chance to have a name clash is smaller.
  • As @mko-io pointed out, Symbols are more familiar to people for such kind of things. They seem to be more idiomatic. So maybe to use Symbols would be more mainstream way, and we want to be mainstream.
  • Also Symbol properties are not enumerable by default. But not sure if this good, bad, or doesn't matter.

@lin7sh
Copy link

lin7sh commented Nov 29, 2016

As far as know, Nodejs is using Symbol for protocol alike thing in the internal module. So more developer would adapt to the idiom for the usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants