a gripe about toString []

Alan Grover awgrover@umich.edu
Wed, 3 Jun 1998 09:31:51 -0500


I'm pretty convinced now that the provided definition of toString on lists
is a mistake. The StdList module has an instance:
instance toString [a] | toChar a

The problems are:
toString typically turns data into a human readable representation, except
for toString [].
toString [Int] should be a human readable representation of a list, not a
packed base 256 structure.
toChar Int is probably a bad idea for a language that otherwise is pretty
safe (cf. C).
No other toString on lists is then possible.
It really means "Encode as base 256, and then pack into a string".

Ok, the language won't let me have different toString's for different types
of lists anyway, and I want to pick my formatting when I change lists to
strings. But I don't like the toString I've got!


---
"Alan Grover, Technical Pb" awgrover@umich.edu
+1 (743) 647-5778
Project Leader
Health Media Research Lab, Cancer Center
5D04 North Ingalls Building, Mail Stop 0471
300 North Ingalls
Ann Arbor, MI 48109-0471