Hi all,
So, I now understand why we have duplicate error checking code.
The original stuff was in:
src/stan/math/error_handling/check_*
src/stan/math/error_handling/matrix/check_*
New stuff was implemented in:
src/stan/math/validate_*
src/stan/math/matrix/validate_*
I'm finding out that the order of header includes for the check_* functions matters a lot. This shouldn't be the case, but it's true now. What ends up happening is that things stop compiling by bringing in an additional header.
I'm going to suggest we reimplement all of our error handling. (By we, I mean I am volunteering and will take anyone else's time if you've got it.) I want to address:
- issue #665 - consolidating error handling code:
https://github.com/stan-dev/stan/issues/655
- issue #640 - eliminate error message when sampling
- untangling this header mess
- simplify error handling by decoupling our error handling from Boost's complex, policy-based error handling.
Fortunately, all the original error handling code has unit tests, so it's easy to validate that the new error handling is the same. Unfortunately, none of the new error handling has any tests, so it'll take a little more time to implement safely than if it all had tests in place.
The biggest design change will be to decouple from Boost's style of error handling. I don't think this is an issue, but here's a list of pros and cons:
Pros:
- much simpler code
- easier to include a single error handling function
- removes the "Error in:" message that Boost provides
- we'd have much more control over error messages
- it'll be a lot easier to break apart our auto-diff library in the future if this section isn't tied into the traits.
Cons:
- no ability to flexibility change behavior, at least for the first incarnation (Note: we don't EVER use this functionality)
Anyone oppose? Anyone want to help? Time estimate -- if I start now, good chance I knock this out by tomorrow's meeting. ~30 existing error check functions with tests, which should take a handful of hours (hopefully under 5 hours). ~15 new functions without tests -- this will eat up a lot of time. Yesterday, I spent about 8 hours moving 3 of them to our existing error check functions. (Anyone that thinks that unit tests don't matter for "trivial" bits of code, they do. It helps make changes like this a lot easier to do.)
Daniel