News for hackers. Stuff that matters.
Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @01:46PM (#28619403)
That's a good point. I would also like very much if languages included a sensible and useful default implementation of toString() or the equivalent for all types (e.g. print all the object's private & public property names & values, recursively, stopping if cycles are found).

Of course, this is probably only remotely feasible in languages that can guarantee that toString() won't have any side effects.

Re:Long Error Messages by gizmo686 on Wednesday September 22, 2021 @03:05PM (#28620367)
You need "side effects" to include memory allocation, seg faults, and "significant" amount of computation time (including never terminating). Worse, you need these properties when the program is known to be in an error state.

For a general purpose programming language this means that your toString cannot be a normal function.

Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @03:57PM (#28621034)
Also good points, I suppose the printing mechanism couldn't use the type's implementation of toString() and would instead have to use an implementation built into the runtime. Still, even being able to see just the raw bytes would be better than nothing in a lot of cases.