Repository navigation
Conversation
|
instead of loosening the requirements, we should change the default implementation to memoize the empty list. |
I don't think there is much value in it, because none of the algorithms rely on the identity of the list (and I don't think the spec relies anywhere on the identity of lists) |
|
if the spec doesn't rely on it, then i'm not sure why this change is needed - and if it does, forcing hosts to return the same identity is a stronger guarantee than simply returning the same contents, and it's never a good idea to loosen host requirements without a strong reason. |
|
Thanks, @ljharb. I opened this PR because |
|
HTML already does not return the same list every time for this AO, but a list with the same contents: https://html.spec.whatwg.org/#hostgetsupportedimportattributes It's much more annoying to write a memoize algorithm than not. |
linusg
left a comment
There was a problem hiding this comment.
Not a fan of this change, we should not introduce more hand-wavy prose like this. If identity is required it ought to be a field on Agent, and if cross-Agent stable identity is required (why??) that ought to be noted explicitly.
HTML already ignoring the current requirement suggests that list equality is a sufficient requirement.
|
@linusg What do you think of the first commit? |
|
That LGTM. |
|
Thanks for the discussion. I lean toward the original change. "AllImportAttributesSupported" only checks whether the returned List contains each attribute key, so keeping the contents and order stable seems sufficient for this hook. This also matches HTML's existing algorithm without requiring a cached List. @ljharb, is there a specific reason we need stable List identity here beyond stable contents and order? |
|
To be clear, changing the requirement (the original change) is normative and requires consensus. Fixing the spec to comply with existing requirements would be editorial. @JinDX off the top of my head I don't have a specific use case, but the wording was discussed and agreed on in plenary, and i feel very strongly that host hooks should be maximally constrained in every possible way, and variance only permitted with a strong argument from the hosts that need a constraint relaxed. |
I don't think there is any observable difference in any program for any possible host? So I don't think that it's normative. |
|
If there's not an observable difference, then what's the point of this PR? |
|
I mean I'm happy to add this to the agenda and present if you think it's needed. We're past the deadline but it's so small that it's probably fine. But I agree there is no observable difference.
The spec is internally self-inconsistent. It requires a property that itself does not respect and that it does not rely on. |
|
I mean, either this isn't an observable difference, or it is. If it's not, then it's editorial. If it is, then it's not. If nothing can possibly care about the identity of the list, then that also means that the default implementation can easily return the same List identify, which would match the normative requirement that has consensus. |
|
It is not observable other than making some hosts potentially in violation of a requirement that has no effect on JS behavior. This situation is as if ECMA-262 had this AO: and both HTML and some ECMA-262 algorithms call it as - Double ( _x_: an integer )
+ Double ( _x_: a mathematical value )
1. Return _x_ + _x_.Anyway, given that plenary is just next week we can talk about it in tc39/agendas#2195. @JinDX Could you remove the second commit, so that it's clear what I will be asking for consensus for? |
cb4c4cc to
32fdff0
Compare
|
Done. I've removed the second commit. Thanks for bringing this to plenary! |
I opened this PR because
HostGetSupportedImportAttributesrequires the same List on every call, but the default implementation returns a new empty List each time.AllImportAttributesSupportedonly checks whether the returned List contains each attribute key, so keeping the contents and order stable seems sufficient for this hook. This also matches HTML's existing algorithm without requiring a cached List.