Gorgi Kosev (2013-12-20T18:00:56.000Z)
domenic at domenicdenicola.com (2014-01-03T17:07:14.815Z)
jQuery was just an example. > The basic idea is that you feature detect for ES6 Promises. If that test passes, then you implement jQuery.Deferred using a Promise subclass (which would do assimilation for backward compatibility reasons). Otherwise you implement it the old-fashioned way. Hold on there. If they already do assimilation, why would you even inherit? So you're saying that promise library authors should rearchitect their entire libraries, and that solution is better than them just adding a flag to their prototype which says "convertableToPromise = true;" ? Which can be monkey patched by end users too? How is this even remotely practical? This is my list of options and what I think about their practicality - full reserving a commonplace method named "then" - impractical, error prone and unfriendly to both existing and new code (accidental then is very possible) - reserving the combination of "then" and "convertableToPromise" - practical, sensible tradeoff (as symbol-based branding isnt available, and accidentally adding both properties isn't very possible) - expecting promise libraries to upgrade by simply setting a flag `convertableToPromise = true` - practical (can also be monkey-patched by end-users) although painful for existing promise libraries and users at the beginning - expecting non-promise libraries to mark their prototypes with `convertableToPromise = false` (assuming true by default) - slightly less practical, but painless for existing promise libraries and users at the beginning. (The intent of course is to flip the switch later) - using symbols for branding/anti-branding - impractical, because it cannot be shimmed - expecting promise libraries to upgrade by subclassing Promise - impractical, some (like Bluebird) have complex, hand tuned performance-optimized internals which even makes them faster than the native implementation, and some have extra features which will need to be re-done in a new way. (full rearchitecting) If you ask me, the only viable options are "ghetto branding" and "ghetto anti-branding".