On June 10, 2013 05:48:01 PM EDT, Ben Goodrich <
goodri...@gmail.com> wrote:
> The TO-DO file has a number of references to user-defined stuff. As a
> simple starting point, can we
>
> -- add a grammar rule so that any function in the .stan file whose name
> ends in __ (or some other magic character combination) is parsed as a
> literal C++ function call
We could do that. There wouldn't be any error checking on the model
function signatures, but presumably that would be OK for a user writing
their own C++.
> -- amend the target in the makefile so if a directory contains both
> foo.stan and foo.hpp, then after parsing foo.stan to foo.cpp the make call
> is like
>
> $(CC) -include foo.hpp -c -o foo.o foo.cpp
>
> which according to the documentation of g++ and clang++ is equivalent to
> manually adding
>
> #include "foo.hpp"
>
> at the very top of foo.cpp. That way a user could declare / define a
> function like bar__() in foo.hpp and use bar__() in foo.cpp that is
> generated from foo.stan.
Cool.
What namespace should they declare the function in or should they
just make it global? We only having "using" statements for some parts
of Stan.
> That seems easy and unlikely to break any existing code, although users
> would be on their own when utilizing anything in foo.hpp. It also lowers
> the barrier where someone maybe wants to try something out before deciding
> to make the effort to get it included in Stan.
It basically saves them having to (a) recompile Stan from scratch,
and (b) declare the function signatures. I'm not sure that's such
a huge savings in terms of work, but anything that lowers the complexity
level is probably helpful.
- Bob