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

Print.h add printf API #32

Open
iZhangHui opened this issue Jun 3, 2019 · 2 comments · May be fixed by #28
Open

Print.h add printf API #32

iZhangHui opened this issue Jun 3, 2019 · 2 comments · May be fixed by #28

Comments

@iZhangHui
Copy link

No description provided.

@cousteaulecommandant
Copy link

See #28

@matthijskooijman
Copy link
Collaborator

matthijskooijman commented Jun 21, 2022

Adding printf seems obvious, but in the past, adding printf support has been discussed (on the mailinglist, I think, I don't have a link at hand), and the main (and so far, I think, decisive) argument against adding printf is that it is convenient, but not a very transparent API for the novice programmer audience. Also, lack of type safety makes it very easy to get hard-to-debug problems using printf. Of course, you could argue that this API is available for more advanced programmers that need it, but if it is offered by default, it will likely going to end up in examples that novice programmers use too and end up causing problems anyway. If an expert user really wants to use printf, there are some libraries that offer a similar thing as well.

Also see the discussion in #28 for some links to previous discussions.

Ideally, some more type-safe and convenient way of printing multiple values would be available (and I've been working on something a long time ago based on a variadic print function), but nothing definitive has come out of that so far. The issue for implementing something better is #34.

I'm not sure if the stance on this has changed, but personally I would very much prefer something that is better to use than plain printf (and with new C++ features, implementing something that is convenient and type-safe is probably more feasible than when printf was conceived).

There currently seem to be two PRs implementing this: #29, which prints byte-by-byte, and #28 which keeps a fixed-size buffer on the stack (which IMHO is needlessly limiting, so I closed it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants