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

Move from getters to configurable non-writable own properties? #35

Closed
Jack-Works opened this issue Jul 10, 2020 · 4 comments
Closed

Move from getters to configurable non-writable own properties? #35

Jack-Works opened this issue Jul 10, 2020 · 4 comments

Comments

@Jack-Works
Copy link
Member

tc39/proposal-promise-any#38

@jorendorff writes:

Getters are for querying internal state; if there's nothing "internal" about it, a data property seems more idiomatic to me.

The argument makes sense for range proposal. The API is designed to be immutable so it's not possible to change step, start, end. Since there is no internal state, it's better to use its own properties.

What if the developer re-configure the options?

// slot+getter
range.includes(2) // impossible to change range.start/end
range.includes.call({start:0, end:5}) // throws
// own property
range.includes(2) // possible to re-configure start/end to change the result
range.includes.call({start: 0, end: 5}, 2) // ok

maybe @erights interested in this (I do want to avoid any new internal slots)

@ljharb
Copy link
Member

ljharb commented Jul 10, 2020

I do not think .call is a usage pattern we'd want to recommend, nor one people would commonly use.

start/end/step are indeed internal state of the range, and thus should be stored in slots.

@Jack-Works
Copy link
Member Author

But those options are immutable, there is no plan to modify it either.

@ljharb
Copy link
Member

ljharb commented Jul 11, 2020

Right - they’re an intrinsic part of a given instance, hence, a slot.

@hax
Copy link
Member

hax commented Jul 12, 2020

We really need some guideline of accessor of internal slots VS. own data property.

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