arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.07k stars 7.01k forks source link

Enhancement/Suggestion: Ability to Declare new Operators #11943

Closed brdane closed 5 months ago

brdane commented 5 months ago

Although such feature isn't within standard C++ standards, it would be useful to programmers to incorporate their own user-defined operators. For example, if a programmer wanted to create an operator to check if a number is between two other numbers, then psuedo-code for that would look like the following:

if (3 between 0 5)
DoSomething();
per1234 commented 5 months ago

Thanks for your suggestion @brdane.

Beyond the minor sketch preprocessing that is done to make it easier and more convenient for people to get started writing Arduino sketches, Arduino keeps the programming language identical to standard C++. It is also not feasible to make significant divergences in the language since Arduino sketches are compiled using standard C++ compilers that Arduino plays no part in developing or maintaining.

So a significant language capability like this would not and could not be implemented by Arduino.

I suggest investigating what is possible to accomplish using the existing capabilities of the Arduino programming language/C++. There is a good chance you can manage something like this already.