Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oprint: Truncate strings only after 8 bytes #10565

Merged
merged 1 commit into from
Aug 28, 2021
Merged

Commits on Aug 27, 2021

  1. 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.
    wikku committed Aug 27, 2021
    Configuration menu
    Copy the full SHA
    c644bdf View commit details
    Browse the repository at this point in the history