-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support arbitrary data type in function block's function signatures #2572
Comments
Perhaps https://www.boost.org/doc/libs/1_67_0/libs/hof/doc/html/doc/ would help |
Not a problem that I'm familiar with. Leave to you guys for a sanity check. |
This is something we'll be addressing in general by adding functional types. We probably aren't going to want to duplicate the effort in the current parser.
The syntax I want to use is something like (real, real):real, for a two-argument
real valued-function. That's what we print out.
As of 2.17/2.18, we have no support for functional types in the Stan language and it'd be a rather substantial effort to add them. The benefit would be that we could remove a bunch of specific grammar rules for functions that take higher-order arguments.
|
That's exactly the syntax I want to see. Is there a timeline for this feature? |
It depends on a number of things. We want to rip out the parser and rebuild it from scratch, so that's going to set things back probably 9 months or so, but then allow us to go much much faster. If that goes too slowly, we'll probably wind up extending the current language to do these things. Either way, very unlikely in the next six to twelve months.
I don't know how we could work around that. We might be able to weaken type checking somehow and add just a generic function type that'd get checked at compile time. That might be workable and a lot easier than building a whole higher-order type-inference system.
|
Yes, something like functions{
func foo;
} and allowing |
Something like that might be workable if we left the actual type-checking of the function to compile time (rather than translation to C++ time).
The reason we want to switch the way we're writing the compiler is that the current infrastructure is such a pain to work with (Boost Spirit Qi---it's all statically typed with super-clever template programs, bindings, etc., which makes it very hard to get things to compile).
|
There is a newer stanc3 issue which is similar: stan-dev/stanc3#1348 |
Summary:
support arbitrary type in external C++ code so
user_header.hpp
can provide higher-order function support.Description:
Currently external C++ function in Stan must be declared in
functions
block with full signature, e.g.This allows user-supplied function. One further step would be to allow user's functions with functor arguments, similar to what Stan has for ODE solvers. Specifically, with that one can do
With this user can supply both ordinary and higher-order functions through C++ headers. Essentially Stan would have some basic plugin mechanism.
I'm not sure how difficult it'll be to realize something like this.
Current Version:
v2.17.1
The text was updated successfully, but these errors were encountered: