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

Runtime: use puts instead of printf("%s\n") #10099

Closed
wants to merge 1 commit into from

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Dec 29, 2020

Minor refactoring (split off from #9284)

@xavierleroy
Copy link
Contributor

I see no good reason for this change.

Performance-wise, these uses of printf are not critical, and GCC gladly optimizes printf("%s\n", s) into puts(s) already.

Legibility-wise, I find printf("%s\n") clearer: it is obvious that a newline is printed after the string, I don't have to remember that puts(s) adds a newline but fputs(s, stdout) doesn't.

@dra27
Copy link
Member Author

dra27 commented Dec 31, 2020

I generally eschew printf unless I need it (but print_endline is, of course, a better named function!). It's gone in the other PRs which caused me to switch it, too!

@dra27 dra27 closed this Dec 31, 2020
@dra27 dra27 deleted the ocamlrun-puts branch July 6, 2021 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants