- From: Anne van Kesteren <notifications@github.com>
- Date: Tue, 05 Sep 2017 07:22:23 +0000 (UTC)
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/pull/426/review/60513155@github.com>
annevk commented on this pull request. > +Additionally, there are semantic differences as well. [=Union types=] are usually used in the sense +that "any of the types would work in about the same way". In contrast, [=overloaded=] operations are +designed to map well to language features such as C++ overloading, and are usually a better fit for +operations with more substantial differences in what they do given arguments of different types. +However, in most cases, operations with such substantial differences are best off with different +names to avoid confusion for Web developers, since the ECMAScript language does not provide +language-level overloading. As such, overloads are rarely appropriate for new APIs, instead often +appearing in legacy APIs or in specialized circumstances. + +That being said, we offer the following recommendations and examples in case of difficulties to +determine what Web IDL language feature to use: + +* In the unusual case where the operation must return values of different types for different + argument types, [=overloaded|overloading=] should be used. <span class="note">This is almost + never appropriate API design, and separate operations with distinct names should be used for + such cases.</span> "Could", "might", "can", "encouraged", "discouraged", "strongly encouraged", and "strongly discouraged" are the words I end up using at times. Some of this seems like it should be requirements, but I guess non-normative is fine for now. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/heycam/webidl/pull/426#discussion_r136911073
Received on Tuesday, 5 September 2017 07:22:50 UTC