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

Make fmt() function more like C's sprintf() #395

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gromgit
Copy link
Contributor

@gromgit gromgit commented Aug 6, 2020

At least reduce the number of cases for Go's dreaded %!d(string=5) to appear when the user applies printf format tags, as shown in #374 (comment)

At least reduce the number of times Go's dreaded `%!d(string=hi)` appears on type mismatch
@gromgit
Copy link
Contributor Author

gromgit commented Aug 6, 2020

This PR now swings in the other direction: %s only works properly with strings. The easy fix, if %s really means "print the canonical representation of whatever it's pointing at", is to replace all %s with %v in evaluator.fmtFn() before calling fmt.Sprintf().

Alternatively, the fmt() portion of https://www.abs-lang.org/types/string could point at https://golang.org/pkg/fmt/#hdr-Printing instead of the current https://linux.die.net/man/3/sprintf, and existing examples be updated to use %v for this purpose instead of %s.

What do you think?

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

Successfully merging this pull request may close these issues.

None yet

1 participant