by kanox · 6y ago · 0 comments
Serialization should require involve separate APIs.
[0] https://docs.microsoft.com/en-us/visualstudio/debugger/using...
I want to be able to design objects that have toString() and I want to be able to design objects that don't have toString().
The same goes for clone(), hash(), getPtr(), getEndian(), equals(), toBytes(), toJson(), encrypt(), delete(), isNumeric(), toXml(), serializationVersion() or compare().
Now I'm wondering... are there languages which formalize "implement with a throw" into some kind of explicit refusal to implement a method? Obviously there are method-sharing approaches other than inheritance, but I've never heard of "you must implement this, or explicitly choose not to".
If they wanted to make it worse, they could make it so you could call %s on any object, and if it wasn't defined, it would "conveniently" fall back to %p instead.
Then someone could could write an article called "Never Use %s for Behaviour"