Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Right, I'm just questioning whether this consistency buys you anything. Either way you're checking the docs to see how to print an object.


> ...I'm just questioning whether this consistency buys you anything.

It buys you the same thing that API consistency always buys you: reduced cognitive overhead when dealing with a given API. :)

Edit: As GFK_of_xmaspast mentions [0] instances of non-trivial classes are not compatible with the default implementations of "operator <<" in ostream. So, you can try "ostream << instanceOfNonTrivial". If it passes the compiler, then you know that operator << is defined for that class.

So, no need to check the docs... just ask the compiler. :)

[0] https://news.ycombinator.com/item?id=10775022




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: