So like many others, before me I’ve created my own Show type class. Which gives me the freedom to design its methods and conventions as I see fit, but it feels like good practice that the
toString method should respect the existing conventions. As much as possible users of one’s classes and traits should not be surprised by the implementations of standard methods. But what are the convention’s for toString?
The Docs just state:
Returns a string representation of the object.
The default representation is platform dependent.
Is toString meant to uniquely identify an object?
3.0 for example identifies this as not an Int, but it could be a Float or a Double. At least given that one knows the type, is toString meant to fully define an object regardless of its character length? Some objects can easily require thousands or tens of thousands of characters for their specification. Is toString "allowed to be multi-line? Is it OK to contain blank lines?
Is HTML allowed within toString. Is the full Unicode character set permissible within toString implementations?
Or is toString just what it is? A rough and ready, poorly specified method that is extremely useful for development but not to be relied upon for production code. Either way I think it would be useful if the Docs could give more guidance.