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

Separate "repr" and "display" string representations #20

Open
p7g opened this issue Dec 17, 2020 · 0 comments
Open

Separate "repr" and "display" string representations #20

p7g opened this issue Dec 17, 2020 · 0 comments

Comments

@p7g
Copy link
Owner

p7g commented Dec 17, 2020

Right now, printing an array is a "repr" type of display (not sure if there is any other alternative), but printing a string or char does not escape any characters, nor does it wrap the value in quotes. This can be annoying when printing an array of strings or characters.

Inspired by Python, it could be something like this:

  1. If a value supports a "to string" operation, use that (this would be the "display" representation)
  2. Otherwise, get the "repr" string for the value. This would look similar to a literal for the value in most cases.
  3. If a value contains other values, the repr for the outermost value should use the repr for inner values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant