-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add formatters for built-in values #19
base: master
Are you sure you want to change the base?
Conversation
@spy16 I'm kinda struggling to sensibly define the formatting directives for Slurp values, and would welcome your input. As I see it, there are basically three special formatting cases for values (as distinct from errors):
It seems like we can distill this behavior down to three orthogonal dimensions:
(These labels are a bit awkward, but bear with me...) So returning to the use-cases at the beginning of this comment:
An edge case would be applying case 2 to a container such as a vector. In this case, it seems like we should not elide type information for members of the container. Thus, rendering Assuming you agree with this assessment, the next question is "how do we encode this in formatting directives?". One approach is:
From there, we could treat the
Formatting can be achieved via
Thoughts? |
Sorry for the long delay in getting back. I am bit confused here to be honest 😅 .. I see only 3 cases like you initially listed down (serialisation, pretty-printing, REPL output).. Even in those cases, serialisation and REPL output are similar except for the fact that REPL output should have some pretty formatting (like shortening long container)..
Note: we could use My only concern with so many combinations of printing is the added complexity & confusion. Hence, the suggestion to not distinguish symbol representation when serialised vs in REPL output (i.e., use |
Hi @spy16 ! No worries, it's been a busy couple of months for me as well.
To be honest ... me too 😝 . It seems I was overthinking this quite a bit, and looking for orthogonality where there is none. In the hopes of restoring some clarity, let me just restate my wishlist. Using
I like this. Also, I'm partial to So in summary:
Sound good? |
Yes. That sounds good 👍 |
In the spirit of #16, this PR adds formatting options for built-in values.
By convention:
%s
returns an s-expression%#s
returns a human-readable representationI considered inverting the two, but wanted to stay consistent with error formatting, where
#
means "pretty".⏱️ Estimated review time: 15 min.
❌ WIP. Do not merge.