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

Why Number(symbol) crashes? #712

Closed
medikoo opened this Issue Oct 14, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@medikoo

medikoo commented Oct 14, 2016

I was searching available resources but wasn't able to find the answer.

What's the reasoning behind having Number(symbol) crash instead of returning NaN (as it's in the case all other non-coercible values that expose some primitive representation)? It feels not consistent.

If someone can point me to some discussion that provided the reasoning I'd be grateful.

I originally posted this question at Mozilla discussion group, but it feels a bit abandoned. If this repository is not right place for such questions, I'll be glad if you direct me to the right one. Thanks!

@leobalter

This comment has been minimized.

Show comment
Hide comment
@leobalter

leobalter Oct 14, 2016

Member

Number(value) calls the abstract operation ToNumber(value), which throws a TypeError when value is a Symbol.

Why do you want to cast a symbol value to a Number?

We have this mailing list for this kind of discussion: http://esdiscuss.org/

Member

leobalter commented Oct 14, 2016

Number(value) calls the abstract operation ToNumber(value), which throws a TypeError when value is a Symbol.

Why do you want to cast a symbol value to a Number?

We have this mailing list for this kind of discussion: http://esdiscuss.org/

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Oct 14, 2016

Member

This doesn't appear to be an issue with the current specification, and as such is not appropriate for this repo. es-discuss or StackOverflow are good ways to get clarification on specification and language usage questions.

Member

domenic commented Oct 14, 2016

This doesn't appear to be an issue with the current specification, and as such is not appropriate for this repo. es-discuss or StackOverflow are good ways to get clarification on specification and language usage questions.

@domenic domenic closed this Oct 14, 2016

@medikoo

This comment has been minimized.

Show comment
Hide comment
@medikoo

medikoo Oct 14, 2016

Why do you want to cast a symbol value to a Number?

I didn't say I want to do that. I said that specification seems inconsistent in handling non-number coercible values, and I'm wondering what's the reasoning.

medikoo commented Oct 14, 2016

Why do you want to cast a symbol value to a Number?

I didn't say I want to do that. I said that specification seems inconsistent in handling non-number coercible values, and I'm wondering what's the reasoning.

@medikoo

This comment has been minimized.

Show comment
Hide comment
@medikoo

medikoo Oct 14, 2016

@domenic I thought http://esdiscuss.org/ is not longer a place where TC39 is involved. Anyway thanks for redirection

medikoo commented Oct 14, 2016

@domenic I thought http://esdiscuss.org/ is not longer a place where TC39 is involved. Anyway thanks for redirection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment