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

Well-known Symbols + configurability/writability #1

Open
ljharb opened this issue Jun 2, 2015 · 4 comments
Open

Well-known Symbols + configurability/writability #1

ljharb opened this issue Jun 2, 2015 · 4 comments

Comments

@ljharb
Copy link

ljharb commented Jun 2, 2015

Would @@undefinedType also then be Symbol.undefinedType, per the established convention for well-known Symbols?

Would they thus be non-configurable/non-writable on Symbol? What about on Reflect.types? Would types itself similarly be non-configurable/non-writable on Reflect?

@alexweej
Copy link
Owner

alexweej commented Jun 2, 2015

Perhaps using the nomenclature of "well-known symbols" for this is incorrect, as they would already be available in Reflect.types.

I'd say the rules for the Reflect.types property descriptors should match whatever they are for Symbol with existing well-known symbols - I can't think of a reason why it should behave differently. As for the type property itself, I'm not really sure. It's hard to predict the needs of the polyfills of the future!

Do you have any ideas?

Thanks

@ljharb
Copy link
Author

ljharb commented Jun 2, 2015

As a shim maintainer, I definitely would want to make sure I'm able to add new type symbols, but to Symbol and Reflect.types. The Reflect.type function itself seems easily polyfillable, provided that symbols exist.

However, Symbols can't be polyfilled - so in any engine without native symbols, how might I polyfill Reflect.type?

Is there a need to return symbols? Simply returning strings seems simpler, even if they were nicely stored in Reflect.types constants.

@alexweej
Copy link
Owner

alexweej commented Jun 2, 2015

I had considered leaving it open as to the exact value type returned by Reflect.type - so long as it was === comparable to the properties in Reflect.types and valid as property keys. That leaves exactly two options - string and symbol. I feel as if symbol is the right choice, shimmability issues aside. Shims have seemed to cope with the fact that Symbol.iterator is needed for the iterable protocol, and simply used strings with a big fat proviso. Is there any reason to believe that approach might cause more of an issue here?

(By the way, thanks for your great work on es6-shim. That thing makes my day job quite a lot more pleasant!)

@ljharb
Copy link
Author

ljharb commented Jun 2, 2015

That's a fair point, indeed.

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

2 participants