I believe there is a larger question embodied here, one that goes to the heart of the mbed rapid prototyping philosophy:
How "rigorous" should an mbed library function attempt to be?
Suppose, for example, a developer in his discretion decides to call a function in the body of his code, and ignore its return value. Clearly, in an ideal world no function would return a value unless it were critical that that value be checked. So in an ideal world, the compiler might try to force the developer to check the return value.
But we are not in an ideal world, and the compiler does not behave that way. In the real world, it is not unusual for routines to return values that are just advisory (such as debugging information), and the developer may choose at times ignore such return values. That is a design decision, and the compiler stays out of it.
After all, the compiler can't know if the return value is meaningful in the context of the rest of the program.
Similarly, the mbed ticker library can't know if an attached function's return value is meaningful or not. But unlike the compiler, the present version of the ticker library does not stay out of it -- instead, it prevents binding non-void functions. No doubt this was done with good intentions, perhaps to encourage the noble practice of always checking return values. But is that appropriate for a rapid-prototyping library used in the real world?
I suggest the library should allow the same latitude to the developer as does the compiler. So, for example, if the developer wants to attach a non-void function to the ticker, that should be permitted. Clearly, the ticker will do nothing with the return value -- but that is exactly what the developer expects. Let him attach his function and get on with his business.
Maybe I am wrong, but I believe that allowing more leeway in ticker.attach would better promote truly rapid prototyping. What say, mbed development team?
I recently coded a function that returned an (int) value, which I used for debugging the function when it was called manually. Then I just hooked it to a ticker without bothering to recode it to remove the return value.
This does not work, as a function returning an (int) is not compatible with the ticker library as it stands. So the compiler objected.
Would it make sense to allow a ticker attachment to be a function that returns something other than (void)?
If that is not a good idea, then perhaps the ticker docs could at least highlight this restriction -- for those of us who don't read the fine print in the library definitions :-)