Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oprint: Truncate strings only after 8 bytes
When we run List.init 300 (Fun.const "a") we can see that the toplevel in one case prints ""... (* string length 1; truncated *) instead of just "a". The comment that the string was truncated takes at least 36 characters, so truncating does not make much sense here. If we are going to print the comment, it doesn't hurt much to also show a part of the string to the user. A byte can be printed as up to 4 characters, due to escaping. So printing strings of length up to 8 bytes will always be shorter without truncating. There are still cases when truncating gives a longer text than not, but it's unavoidable if the length of the printed prefix is a nondecreasing function of the string length.
- Loading branch information