-
Notifications
You must be signed in to change notification settings - Fork 163
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
Consider removing fallback paths in CalendarFields and CalendarMergeFields #2310
Comments
I believe we did keep these intentionally even though the rest of the fallbacks were not present, because many userland calendars wouldn't have to have these. I don't feel strongly either way though. |
cc @sffc |
In the champions meeting of 2023-01-05 we decided to accept @anba's recommendation to remove these in order to reduce complexity in the proposal. |
@ptomato i'm not seeing anything in here that explains the benefits of removing the fallbacks. All I've seen is points about how it might not be that harmful to remove them. |
Note, DefaultMergeCalendarFields still exists in this branch but one use of it would be removed in #2310, and #1418 would consolidate this definition of Temporal.Calendar.prototype.mergeFields() with the earlier one in the 262 part of the proposal. So ultimately, this would be the only definition of mergeFields. To do, if we decide this is the right approach: - Check that all the places that might produce abrupt completions are correct - Change the reference code to follow this spec
This pulls as much logic as possible out of the calendar-dependent operation into algorithm steps that are common to all calendars, in order to address the implementor questions about the previous definition of the operation. Note, there is the potential for a rebase conflict with #2310, which removes one use of DefaultCalendarMergeFields and renames it to ISOCalendarMergeFields.
This pulls as much logic as possible out of the calendar-dependent operation into algorithm steps that are common to all calendars, in order to address the implementor questions about the previous definition of the operation. Note, there is the potential for a rebase conflict with #2310, which removes one use of DefaultCalendarMergeFields and renames it to ISOCalendarMergeFields.
This pulls as much logic as possible out of the calendar-dependent operation into algorithm steps that are common to all calendars, in order to address the implementor questions about the previous definition of the operation. Note, there is the potential for a rebase conflict with #2310, which removes one use of DefaultCalendarMergeFields and renames it to ISOCalendarMergeFields.
This pulls as much logic as possible out of the calendar-dependent operation into algorithm steps that are common to all calendars, in order to address the implementor questions about the previous definition of the operation. Note, there is the potential for a rebase conflict with #2310, which removes one use of DefaultCalendarMergeFields and renames it to ISOCalendarMergeFields.
@ptomato i understand this has consensus, but nobody yet has explained why this is a good thing. |
Sorry, I assumed this had been answered by the slide I presented. Here's a slightly more elaborate, non-slide-deck-based explanation: There were two reasons to have these fallbacks:
With the optimization from #1808 adopted, built-in calendars no longer observably look up methods. Guarding against deleted prototype properties is no longer necessary in most cases, because built-in calendars will continue to work the same if those properties are deleted. Also with #1808, we now require objects implementing the Calendar protocol to implement all of the methods anyway, so that we can unambiguously say whether an object implements the protocol or not — the way we distinguished this previously was a confusing, weird corner of the proposal, which is now able to be eliminated altogether. So omitting With those two reasons no longer applying, we didn't see any reason to push back against the request for less complexity. So as a literal answer to your question, I guess "less complexity, because it turned out not to be needed" is the good thing. |
Gotcha, thanks for typing it out. |
This pulls as much logic as possible out of the calendar-dependent operation into algorithm steps that are common to all calendars, in order to address the implementor questions about the previous definition of the operation. Note, there is the potential for a rebase conflict with #2310, which removes one use of DefaultCalendarMergeFields and renames it to ISOCalendarMergeFields.
CalendarFields and CalendarMergeFields both have fallback paths when
"fields"
resp."mergeFields"
isn't present. This approach isn't used anywhere else in the Temporal spec, for example all other Calendar API methods are required and will throw an error when they aren't present on an Calendar-like object.I'm not sure if this is just a left-over from the initial design, which had more fallback paths. For example certain
Temporal.TimeZone.prototype
methods didn't contain brand checks and were applicable for any object. One example:getPlainDateTimeFor
property wasn't present. AndTemporal.TimeZone.prototype.getPlainDateTimeFor
was applicable for any object.The minimal implementation for both methods is relatively simple, so it shouldn't be too much to ask that users provide their own implementation.
fields
just needs to return its input.mergeFields
combines both objects and has to perform some special-casing for"month"
and"monthCode"
.It's also worth noting that user-defined calendars which use fields like
"era"
and"eraYear"
have to define their own version ofmergeFields
anyway.Minimal implementation example:
The text was updated successfully, but these errors were encountered: