Re: [whatwg/webidl] Allow static operations to have the same name as regular operations (Issue #1097)

`Response` objects have a `json()` instance method to read its response body and parse it into a JSON object. There's a proposal to add a static method to make it more easy to create `Response` objects that have a JSON response body. Given the names of current static methods on `Response` objects that exist for the creation of `Response` objects, `json()` would be a good name there too.

In usage I'm not sure this ends up being confusing, but I suppose it could be depending on how familiar the reader is with static methods. `Response.json()` is for creation, `responseInstance.json()` is for reading.

---

I think @yuki3 has found the reason this was likely removed. Java and Rust don't support this. I couldn't find anything conclusive on C++. I doubt this is a problem for Wasm. @lukewagner?

Nowadays I'm not sure that is of concern, except for possibly Wasm. I think we're more aligned on the idea that Web IDL is for the web and non-web languages would be better of with APIs suited to their design.

---

So the trade-off here is "most logical name" vs "potential confusion" and "potential implementation inconvenience" (as implementations do want to use Web IDL for non-web languages for internal usage so they need some kind of mapping).

Unless there is "potential confusion" I'd argue "most logical name" wins, but there might be arguments I've missed.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1097#issuecomment-1032367175
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1097/1032367175@github.com>

Received on Tuesday, 8 February 2022 09:01:12 UTC