-
Notifications
You must be signed in to change notification settings - Fork 159
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
Should from() always return new objects? #341
Comments
from() should delegate to, e.g., the |
I support this change even more after discovering that you otherwise cannot balance an existing Duration by calling |
I didn't notice before, but this is a duplicate of #232. |
#232 appears to have been resolved without an explicit decision on this point; I'm going to reopen it to avoid further duplication until that happens. |
I'm fairly sure we have decided in some other context that from() always returns a new object (except for TimeZone and Calendar where it cannot), just not in the context of #232. |
I think the language in the slides is ambiguous and could be changed, but the spec text is correct as far as I can tell; ToTemporalFoo returns the same instance when used internally for coercion, but Temporal.Foo.from contains an extra step that clones the object if it is already of the correct type. |
I double-checked this, and there was indeed a discrepancy in the ZonedDateTime.from spec text. I've opened a pull request to address it. |
In #231 (comment), @ljharb says:
It seems like
Temporal.Date.from(temporalDate)
would be the most sensible way to support this requirement, more so than anything involvingwith()
.I seem to recall that we discussed this before, but I can't find the discussion now.
The text was updated successfully, but these errors were encountered: