Refactor: encapsulate variadic functions in typechecking #1259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In anticipation of #576 and potential future variadic higher-order functions, I decided it was worth taking a good look at cleaning up the shared code between existing variadic functions.
The DAE and ODE functions, and the future
solve_newton
etc are completely described by a few rules:control_args
)?This PR reorganizes the existing code around this to remove current duplication and prevent more going foward.
Note that the above are not sufficient to capture
reduce_sum
, since item 4 is actually dynamic depending on the first argument. So, for now at least, this is left as a special case.This would also let us try to print these as part of
--dump-stan-math-signatures
eventually, if we wanted to.Finally, I'd like to note that it would eventually be nice to also clean up the code gen for these higher-order functions, which is currently also very special cased due to the differing positions of arguments, different requirements for functors being generated, etc.
Submission Checklist
Release notes
Replace this text with a short note on what will change if this pull request is merged. This will be included in the release notes.
Copyright and Licensing
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)