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

Redundancy in the `ToLength`? #721

Closed
zerkms opened this Issue Oct 27, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@zerkms

zerkms commented Oct 27, 2016

http://www.ecma-international.org/ecma-262/7.0/#sec-tolength

The step 3 there is an explicit comparison with the +Infinity.

What is the point to have it there, as long as it will be handled by the last step Return min(len, 2^53-1). anyway.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Oct 27, 2016

Member

I think this is a case where the redundancy does no harm and is actually helpful to readers of the spec.

Readers look at the ToX abstract operations when they need verify, for themselves, how specific cases are handled. In such situations it is easier to see an explicit statement of how +Infinity is handled than to have to remember or lookup that max() is defined to work with +Infinity.

Member

allenwb commented Oct 27, 2016

I think this is a case where the redundancy does no harm and is actually helpful to readers of the spec.

Readers look at the ToX abstract operations when they need verify, for themselves, how specific cases are handled. In such situations it is easier to see an explicit statement of how +Infinity is handled than to have to remember or lookup that max() is defined to work with +Infinity.

@leobalter

This comment has been minimized.

Show comment
Hide comment
@leobalter

leobalter Oct 27, 2016

Member

This step was an useful reference when I wrote tests for TypedArrays, I imagined the same applies to runtime implementors. That's a case when clarity wins brevity.

Member

leobalter commented Oct 27, 2016

This step was an useful reference when I wrote tests for TypedArrays, I imagined the same applies to runtime implementors. That's a case when clarity wins brevity.

@zerkms

This comment has been minimized.

Show comment
Hide comment
@zerkms

zerkms Oct 27, 2016

@allenwb @leobalter then for consistency it should be another step that checks for -Infinity.

If len is -Infinity return +0

zerkms commented Oct 27, 2016

@allenwb @leobalter then for consistency it should be another step that checks for -Infinity.

If len is -Infinity return +0

@chozzz

This comment has been minimized.

Show comment
Hide comment
@chozzz

chozzz Oct 28, 2016

@zerkms They already did that on step 2.

If len ≤ +0, return +0.

chozzz commented Oct 28, 2016

@zerkms They already did that on step 2.

If len ≤ +0, return +0.

@zerkms

This comment has been minimized.

Show comment
Hide comment
@zerkms

zerkms Oct 28, 2016

@chozzz sure.

That's my exact point: if it is fine to expect -Infinity less than zero, then it would be equally fine to expect +Infinity greater than 2^53-1.

zerkms commented Oct 28, 2016

@chozzz sure.

That's my exact point: if it is fine to expect -Infinity less than zero, then it would be equally fine to expect +Infinity greater than 2^53-1.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 14, 2016

Member

Editorially I am fine with the current spec text in this regard.

Member

bterlson commented Nov 14, 2016

Editorially I am fine with the current spec text in this regard.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 23, 2016

Member

There is now evidence of three people being confused by this. Since the min part is fairly straight forward I guess we'll remove the redundant check and rely on implementers to understand how max/min work with +/-Infinity.

Member

bterlson commented Nov 23, 2016

There is now evidence of three people being confused by this. Since the min part is fairly straight forward I guess we'll remove the redundant check and rely on implementers to understand how max/min work with +/-Infinity.

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