-
Notifications
You must be signed in to change notification settings - Fork 157
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
Make fields enumerable own (data?) properties on instances #917
Comments
Feedback from April 1 TC39 (https://github.com/tc39/notes/blob/master/meetings/2020-03/april-1.md#temporal-update):
|
Existing examples of own properties:
|
It's notable that the vast majority of those are legacy. I'm totally on board with being able to ergonomically make a DateTime from |
OK, more recent examples:
There is significant construction of values that are similar to property bags throughout ECMAScript, and Temporal already makes heavy use of that pattern for input (e.g., Are you opposed to this change, and if so can you explain why? |
I'm opposed to adding own properties for all the fields, because the prevailing pattern ES6+ has pushed hard to use is to prefer slot-revealing prototype accessor properties (which wouldn't show up in spread). I am opposed to making them all own properties solely for use in object spread, because I don't think the inconsistency is worth the ergonomics, and because I'm not convinced there's no other alternative. For example, |
FWIW, while experimenting with Temporal-based forks of some D3 modules, I hit a testing problem due to the lack of own properties. D3 uses To fix my experiment, I just did a hacky patch of Personally, I'm not specifically for or against exposing own properties, just giving a data point. But I was certainly initially surprised when I found the source of the bug. |
@gilmoreorless for deep-equal, since Temporal objects are builtins, it would brand-check them (like it does for Dates, RegExps, etc) and check their internal slots - so a lack of own properties wouldn't be an issue there. You're correct that in the meantime, own properties would "just work" for these libraries. |
Summary of discussion in Oct. 9 meeting: Both prototype properties and own properties have advantages and disadvantages, so either way the solution is a tradeoff. Since prototype properties are the norm, the burden of convincing is higher if we were to propose a solution involving own properties for Temporal. None of the current champions feel strongly enough about this issue to spend the required effort advocating for own properties, so we are closing this issue for lack of a champion. We would reopen it if a champion presented themselves, given that there was not universal opposition in the September TC39 plenary. |
@ptomato was there a decision on how to ergonomically support creating a DateTime from a Date and a Time? |
I believe that's addressed by #889. |
This is a rehash of #403 in response to feedback about Temporal being overly verbose. It seems like supporting
Temporal.DateTime.from({...date, ...time})
rather than requiringTemporal.DateTime.from({...date.getFields(), ...time.getFields()})
(cf. #720) would be an easy win, and would have the additional benefit of making Temporal instances behave more like Record values. Such properties, whether implemented as accessor or data properties, would reflect the immutability of Temporal instances by theirselves being immutable.Further, if this is rejected then the rationale should be well-documented (unlike #403, which claimed a "consensus" that was not adequately captured in meeting notes).
The text was updated successfully, but these errors were encountered: