News for hackers. Stuff that matters.
Re:What makes a good REPL? by chrissnell on Sunday August 27, 2017 @09:42PM (#15113907)
Pretty-printing of data structures in a human-readable format.
Re:What makes a good REPL? by yorwba on Monday August 28, 2017 @03:22AM (#15114957)
I think Jupyter has the right idea here with various kinds of repr-alternatives that can render html or images directly into the notebook. http://ipython.readthedocs.io/en/stable/config/integrating.h...
Re:What makes a good REPL? by junke on Monday August 28, 2017 @03:37AM (#15115010)
This is the kind of use cases where multiple dispatch is useful.
Re:What makes a good REPL? by yorwba on Monday August 28, 2017 @05:13AM (#15115350)
How so? I feel like single dispatch (as in Python) is already enough.
Re:What makes a good REPL? by junke on Monday August 28, 2017 @05:42AM (#15115458)
If you write a custom _repr_html_, you are likely to assemble subparts by recursively calling _repr_html_ on sub-elements (thanks to open recursion). If you have an object B which inherits from A, you can specialize on B, or use the existing method for A.

However, you cannot specializes the "html" part with inheritance. Say for example that you want to define a slightly different _repr_html_ method depending on the context (maybe you target the subset of HTML that works correctly in emails) or if you want to render "latex" with custom "tikz" macros instead of using matplotlib.

With multiple dispatch, you can specialize on the target too, which means you can specialize wherever required or fall back to a generic behavior if not.