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

More formal definition of array index #900

Open
annevk opened this Issue Apr 18, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@annevk
Contributor

annevk commented Apr 18, 2017

https://tc39.github.io/ecma262/#sec-array-exotic-objects seems to define array index somewhat informatively. Could there be a more formal definition there so it can be reused by IDL?

You probably also do not want to define it only for String properties, since as far as I can tell https://tc39.github.io/ecma262/#sec-array-exotic-objects-defineownproperty-p-desc can invoke it upon a Symbol, for which it would not be defined?

Something like an IsArrayIndex abstract operation would be great.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Apr 18, 2017

Contributor

Array index is more formally defined in https://tc39.github.io/ecma262/#sec-object-type.

Contributor

anba commented Apr 18, 2017

Array index is more formally defined in https://tc39.github.io/ecma262/#sec-object-type.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Apr 18, 2017

Contributor

That still only defines it for Strings as far as I can tell.

Contributor

annevk commented Apr 18, 2017

That still only defines it for Strings as far as I can tell.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Apr 18, 2017

Contributor

For the couple of uses of integer and array index it seems using abstract operations would be much clearer overall.

Contributor

annevk commented Apr 18, 2017

For the couple of uses of integer and array index it seems using abstract operations would be much clearer overall.

@rwaldron

This comment has been minimized.

Show comment
Hide comment
@rwaldron

rwaldron Apr 20, 2017

Contributor

From https://tc39.github.io/ecma262/#sec-object-type:

An array index is an integer index whose numeric value i is in the range +0 ≤ i < 232-1.

Did you want something more explicit, eg. with an esid of its own?

Contributor

rwaldron commented Apr 20, 2017

From https://tc39.github.io/ecma262/#sec-object-type:

An array index is an integer index whose numeric value i is in the range +0 ≤ i < 232-1.

Did you want something more explicit, eg. with an esid of its own?

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Apr 20, 2017

Contributor

Basically something where https://tc39.github.io/ecma262/#sec-array-exotic-objects-defineownproperty-p-desc step 3 doesn't have a logic error when P is a Symbol and ideally something where you can pass P (even when being a Symbol) to an abstract operation IsArrayIndex() that handles all these details and returns either true or false.

Contributor

annevk commented Apr 20, 2017

Basically something where https://tc39.github.io/ecma262/#sec-array-exotic-objects-defineownproperty-p-desc step 3 doesn't have a logic error when P is a Symbol and ideally something where you can pass P (even when being a Symbol) to an abstract operation IsArrayIndex() that handles all these details and returns either true or false.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Apr 20, 2017

Contributor

I still don't see where 9.4.2.1 contains a logic error. Array indices are a subset of integer indices, and integer indices are a subset of String-valued property keys. So every array index is a String-valued property key.

Contributor

anba commented Apr 20, 2017

I still don't see where 9.4.2.1 contains a logic error. Array indices are a subset of integer indices, and integer indices are a subset of String-valued property keys. So every array index is a String-valued property key.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Apr 20, 2017

Contributor

You're right, I read it the wrong way. Still, I think an abstract operation would be much clearer.

Contributor

annevk commented Apr 20, 2017

You're right, I read it the wrong way. Still, I think an abstract operation would be much clearer.

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