Skip to content

Get rid of boolean type; use bool instead #4673

Open
@cousteaulecommandant

Description

@cousteaulecommandant

Is there a need for the boolean type at all, other than backwards compatibility?

Currently, Arduino's boolean type is defined as an alias to bool (thanks, Chris--A!). However I don't see the need to have a custom boolean type when C and C++ already provide one.
Advantages of the bool type are:

  • it is shorter
  • it is standard
  • it is consistent with other "abbreviated" C and C++ types such as int and char

I think it would be a good idea to stop using this custom boolean type and instead use the bool one; in my opinion, the fewer unneeded additions Arduino makes to the language, the better.
The steps for moving would be (in this order):

  • Replace all boolean from Arduino core and library functions with bool.
  • Update the documentation, removing all references to boolean and replacing them with bool (and maybe adding a note that the boolean type is deprecated).
  • State that the boolean type is deprecated. An __attribute__ ((deprecated ("use bool instead"))) on the boolean definition could be a good idea.
  • Eventually, a few versions after deprecating boolean, consider its removal. (Or leave it there forever, just in case.)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA request to make an enhancement (not a bug fix)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions