I am using Windows10. In 1.8x I used a default argument for a function, as in:
int takeAction(int DoIt, waitime=_defaultWaitTime)
{ .... }
If I didn't pass in an argument for waitime, then the default was used, just as in C++.
With IDE 2.0 BETA 9, I get an error with all calls to the function that don't pass in the second argument. This was code that worked fine with V 1.8x.
I did more analysis. The error I get is "Error: too few arguments to function 'int takeAction(int, int)' and it refers only to a block of code where I define the takeAction() function because the compiler complains it isn't in scope. My code is broken down into 3 tabs. The takeAction() function is in one of them. It is invoked by a function in the same tab, and there I've no problem. It was to solve a different issue that I put a call to the takeAction() function in another tab. However, I'd thought the different tabs was just for ease of programming, that everything was all at the same level. I never before had an error caused by invoking a function from one tab to another.
Getting this scope error, I declared takeAction(int, int) outside the code -- before setup and loop(), right after the includes. Because the second parameter (an int) isn't shown to be optional in this declaration, is the reason I got the error. Please note that in the function implementation I specify int, int as in takeAction(int doIt, int waitime=defaultWait);
I think this issue is a quirk that's easily solved by passing a 0 for the second parameter. I will most likely research the issue some more, but at least I have a solution. I think I need educate myself on how to declare an extern function with a default parameter.
If you give a default argument to a function in a sketch, the parser does not create a prototype declaration, so it can not compile without write prototype in myself.
It's success to compile if you write that function before actually use it.
I thought that Arduino keeps in mind that we can easily write a function without having to good knowledge about the prototype and C++.
But if you want to create a function with default arguments in C++, you need to declare the default value only in the prototype.
However, I think this goes against the Arduino principle of hiding prototype declarations from users.
Please provide a complete minimal demonstration of the problem.
.ino file tabs are all concatenated into a single file by the sketch preprocessor before compiling. The order of concatenation is the file that matches the sketch folder name, followed by the other .ino files in lexicographical order.