Get rid of `boolean` type; use `bool` instead
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
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!](https://github.com/arduino/Arduino/issues/2147)). 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.)
Contributor guide
Research direction
Start by auditing the Arduino core and library functions for uses of `boolean`, then review the `boolean` definition and documentation references mentioned in the issue. Compare the proposed replacement, deprecation note, and eventual removal against backwards-compatibility requirements; done means the migration plan and affected areas are agreed before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- embedded-iot
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100