The credit goes to @fedebenelli who suggested it early in this thread.
I have the impression we might be assigning slightly different meanings to the same words. I don’t see a fundamental difference between the integration example in Note 12.18 and my root-finding example involving the fraction factor. We have discussed similar issues related to passing callback functions and safe multithreading before, just to remind you of two:
- Modern Fortran interface for NLopt - #15 by ivanpribec
- Modern Fortran interface to ODEPACK - #24 by ivanpribec
A recurring limitation in this discussion has been that the subroutine solver
cannot be modified to accept a context argument (e.g. a derived type or similar). But given your expectation that compiler implementors should tackle the executable stack issue, and that the Fortran standard should ideally evolve to support better mechanisms — wouldn’t it also be fair to ask whether the third-party solver
could be adapted too? It’s worth remembering that the word software (as opposed to hardware) implies flexibility:
software
- (computing) Encoded computer instructions, usually modifiable (unless stored in some form of unalterable memory such as ROM). [emphasis added]
@certik has also remarked above that,
… most 3rd party libraries allow you to pass user data. If they don’t, that’s a deficiency of the 3rd party library I think.
In another setting, a compiler expert once told me:
“When the need for a feature can be addressed in portable open-source libraries that are available today (or in a few years), experience shows that that’s a much better solution than trying to change the language. […] If you have a library implementation today, and it’s portable and universally available, you already have the best solution.”
I wanted to conclude my post with an (ironic) quote from Alan Perlis’s Epigrams on Programming. There are several which resonate with this thread, for instance
“Adapting old programs to fit new machines usually means adapting new machines to behave like old ones.”
Sometimes, asking the language or compiler to bend is the harder road — especially when a small change to the signature of solver
could go a long way.