JuliaLang/julia — pull request #4375 by stevengj (2013-09-26 14:07:50+00:00)
Title: RFC: change mimewritable to take instance rather than type

This patch changes the `mimewritable` function to be called as `mimewritable(mime, x)` rather than `mimewritable(mime, typeof(x))`, i.e. to accept an instance rather than a type. This makes it much more flexible, because not all instances of a given type may be writable to the same MIME types.

The necessity for this patch arose in stevengj/PyCall.jl#43, because not all `PyObject` instances will implement the [IPython display API](http://nbviewer.ipython.org/url/github.com/ipython/ipython/raw/master/examples/notebooks/Custom%20Display%20Logic.ipynb), and even those that do will sometimes support different MIME types depending on the instance (e.g. for `IPython.display.Image` instances it depends on the image source).

This breaks backwards compatibility. However, as far as I can tell, the only package currently using `mimewritable` is IJulia, and I've [patched IJulia](https://github.com/JuliaLang/IJulia.jl/commit/2c9b31731a44e08d4a9d67c8506a8cc7a147491e) to work with both versions of the API.