Skip to content
  • Sponsor arduino/ArduinoCore-API

  • Notifications You must be signed in to change notification settings
  • Fork 131

Print.h add printf API #32

@iZhangHui

Description

@iZhangHui
No description provided.

Activity

cousteaulecommandant

cousteaulecommandant commented on Jun 16, 2019

@cousteaulecommandant

See #28

matthijskooijman

matthijskooijman commented on Jun 21, 2022

@matthijskooijman
Collaborator

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).

linked a pull request that will close this issueAdd printf to print class #28on Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Print.h add printf API · Issue #32 · arduino/ArduinoCore-API