-
Notifications
You must be signed in to change notification settings - Fork 152
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
[[Calendar]] in Temporal.PlainTime and GetISO8601Calendar() #1588
Comments
I think what you said in the # comments is correct: you can choose not to create the calendar in the constructor, and only create it in the |
The problem I don't understand is, if the calendar in the internal slot of PlainTime is always iso8601 calendar, then why we need to create one and store in it's internal slot? We do we not to create it when we really need to have one but force to always create on in the PlainTime constructor and carry it around, even it is just a "constant" in the system. |
I don't think it's forced to be created in the PlainTime constructor, since that creation is not observable. |
Creating it in the constructor unobservably, though, is a strong signal to implementors that the semantics must be as if it's created there. |
I agree, and additionally I believe that agrees with all but the final paragraph of the OP. |
What I do not understand is why do this object carry a calendar if it is not used by the object and it is always iso8601? It seems forcing the implementation to waste memory for nothing. Even if we somehow lazy create that, the spec make sure the PlainTime need to reserve a reference to the created one and always return the same one later- the fact the PlainTime need to have a place to remeber what got return the first time and always return the same one later while everyone of them which got return is the same kind is really a waste and inefficency. |
@justingrant @sffc @ryzokuken . |
PlainTime carries a calendar because we believed it is necessary, if we ever want to add time calendars without breaking the web. See #522 and https://github.com/tc39/proposal-temporal/blob/main/meetings/agenda-minutes-2020-11-12.md#time-calendars for more context. |
If we truly believe it is necessary to carries a calendar, then we should allow the constructor to pass in one and not mandate the internal slot to always carry an ISO8601? How we would not breaking the web years later if all the code on the web already assume the one return by PlainTime is always ISO8601 and then somehow it all of sudden start to return some other calendar. In that sense, it will still break the web, right? |
It was mainly a discussion about the semantics of |
@sffc Didn't we remove spreading use-cases when we removed |
Since PlainTime instances can no longer be spread, does that remove the break-the-web concern? It at least removes the concern about
This is also a concern for PlainDate etc. Unfortunately a lot of code will assume these are also always ISO 8601 and that's why we have all of these mitigations as described in The Unexpected Calendar Problem. This is a separate problem from the concern about time-aware calendars breaking the web. |
sorry, I have no idea what is " ... spreading" . My point is if we need to make a decision here, either
I think currently the requirement of the combination of
|
Meeting, Sept. 2: We would like to remove the |
This will be closed by the change we will make in #1808. |
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: tc39#1808 Closes: tc39#1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalLikeObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalLikeObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588
PlainTime now has no calendar. Removes the getter and the internal slot. Calendar annotations are now ignored in ParseTemporalTimeString. RejectObjectWithCalendarOrTimeZone still rejects PlainTime, so it is renamed to RejectTemporalLikeObject. ToTemporalCalendar rejects PlainTime explicitly instead of looking for its `calendar` property or treating it as a plain object calendar. See: #1808 Closes: #1588 UPSTREAM_COMMIT=61fbb401df7463e435b8e6f932de123fd5bc0c2d
Currently, in Temporal.PlainTime Instances
https://tc39.es/proposal-temporal/#sec-properties-of-temporal-plaintime-instances
[[Calendar]] | An instance of the built-in ISO 8601 calendar.
and
https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltime
11. Set object.[[Calendar]] to ? GetISO8601Calendar().
So... what is the value for the Temporal.PlainTime carry this internal slot if the slot is always getting the same kind of calendar (but different object) and the calendar internally carry no state information. It force the implementation to use more memory than it needed to and provide no value.
from what I can I read the spec mandate us to make sure the following
let a = new Temporal.PlainTime(....)
let b = new Temporal.PlainTime(....)
# different Temporal.PlainTime must return different object of Temporal.Calendar)
# so my implementation can NOT cache one Temporal.Calendar object per identifier and re use it
# for all reference to that "iso8601" calendar.
a.calendar == b.calendar => must be false
# different calls to the get Temporal.PlainTime.prototype.calendar must return the same Temporal.Calendar object
# so my internal implementation can NOT choose not to create the calendar in the constructor but only create one
# in the get Temporal.PlainTime.prototype.calendar
a.calendar == a.calendar => must be true
Please forgive me if I misunderstand the interpretation of the spec. I try to figour out how to optimize the memory usage for PlainTime. My first intutiion is that since the calendar is always iso8601 there are no need to create on and store it into the internal slot and we could skip a pointer in the PlainTime internal storage and always call GetISO8601Calendar() to return a new copy in the getter of calendar.
The text was updated successfully, but these errors were encountered: