-
Notifications
You must be signed in to change notification settings - Fork 166
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
Extend the dfn of object types. #211
Conversation
Update [SameObject] and [NewObject] to rely on it. Fixes whatwg#71 Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=27605
the [=promise type=], | ||
the [=exception types=], | ||
the [=buffer source types=], and | ||
[=union types=] whose [=member types|members=] are [=object types=] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/are/contain/, no? Otherwise a union with a string would not be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise a union with a string would not be considered.
Mistakenly thought this was the point. Good catch.
Do we have to account for null types, especially within unions? i.e. are the following object types (currently neither are, if my understanding of what I wrote is correct)? (DOMstring or DOMException?)
(float or (DOMstring or DOMException)?) |
This LGTM but I'd like @bzbarsky and/or @heycam to check, as I'm not confident about the cases like union types or null types. For example I'm not sure we actually want [SameObject]/[NewObject] to apply to |
Two questions for @bzbarsky so I can fix and merge this:
|
Good question. For a return value that doesn't always return an object (i.e. the latter case), it's not clear what [NewObject] would really mean. Or rather, the current definition of [NewObject] as "a reference to a newly created object must always be returned" doesn't make sense in that case, right? Nullable types have the same concern. That makes the given PR not really make much sense, when read literally. We could make that definition more complex to make it more broadly applicable, of course. But normally [NewObject] functions would be some sort of a "construct an object and return it" function. It's pretty odd to allow such a thing to also return non-objects. What is the fetch use case here? |
Agreed, my initial commit read:
I'm not sure. @annevk? |
It's what I had in mind, but I'm open to considering the other option, and a more complicated definition of [NewObject], once I understand the use cases. Note that [SameObject] need not be restricted to the same types as [NewObject]; we can have a [Constant] annotation that makes sense for all types, not just object types.... and I think we should have done that instead of [SameObject]. |
If the issue is just the name, I'm sure we can find something more suitable than [NewObject] to express the opposite of [Constant]. |
Well, the opposite of [Constant] is "yeah, it might change". [NewObject] is not the same thing as the opposite of [Constant] at all. ;) |
Yeah, I meant something with the same semantics as [NewObject] but whose name would make sense for literals too. |
Sorry, for Fetch I only need [NewObject] to work for promises. I don't need it to work for strings or nullables. I think I ended up confusing this issue a bit. #212 (and its corresponding Bugzilla bug) has a proposal for revamping [SameObject]. I agree with @bzbarsky that we don't have to retain parity with [NewObject]. [SameObject] or [Constant] should be its own thing with its own semantics that make sense for it. |
It's absolutely all your fault. :) There are currently no use cases for the
On the other hand, as @dontcallmedom mentions in #71, The ServiceWorker spec uses a bunch of constructs with a nullable type, e.g.: [SameObject] readonly attribute (Client or ServiceWorker or MessagePort)? source; Would something like this work to cover that use case and still make sense given the dfn name?
|
I don't think we should focus on addressing [SameObject] use cases here. I think everyone is coming around that we want to do it differently per the other issues. If we did that, we'd automatically account for nullables and strings and such there I think. |
Well, my understanding is the only difference between the requirements is Given |
Here's a concrete example of why the current [SameObject] thing is silly: Node has various string-or-null-valued attributes (localName, namespaceID) that can never change and we should be able to annotate that. Right now we can't. |
@tobie do we have a case where a [NewObject]-operation can return null or a string? On the face of it something like that seems rather weird. |
@bzbarsky wrote:
Oh, OK. So there are requirements I wasn't aware of. So what's the plan?
@annevk wrote:
I wasn't aware string was a requirement for [SameObject]. Agreed it's potentially a bit weird for [NewObject] but |
Maybe not absurd, but if we have no legit cases… I think we should just remove [SameObject] when we add the improved version and file issues downstream. |
What's the process for removing something like that? Keep it around the spec and mark it as deprecated? Remove it altogether? How do we easily know what specs to file against? Or should we just get a warning out in Bikeshed and Respec and hope for the best? |
Just doing it and gradually fixing dependencies seems fine. Browser engineers can prolly grep all IDL files too to see what needs fixing. |
This needs to be completely revisited. Closing. |
Update [SameObject] and [NewObject] to rely on it.
Fixes #71
Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=27605
Preview (#dfn-object-t…) (#NewObject) (#SameObject) | Diff w/ current ED | Diff w/ base