[FR] UDFs taking another UDF as argument
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 160
- Forks
- 59
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 26
Description
A bit of a nice-to-have for simplifying more complex models would be the ability to pass a functions as an argument to another function.
With suggested signatures like:
functions {
real mult(int x, real y) { return x * y; }
real div(int x, real y) { return x / y; }
real calc((int, real): real functor, int x, real y) {
return functor(x, y);
}
}
And usage:
int a = 1;
real b = 2;
real calc_mult = calc(mult, a, b);
real calc_div = calc(div, a, b);
And if it's not too tricky an additional request, being able to declare/assign functions would be great as well:
(int, real): real functor;
if (operation == 1) {
functor = mult;
} else {
functor = div;
}
real result = calc(functor, a, b);
Note that the above is a highly contrived and simplified example
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by locating how stanc3 parses and represents user-defined functions and function signatures, then determine the scope needed for passing and assigning functions. Done means the proposed examples are accepted and compile with the intended behavior, with tests covering both forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100