-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
featureNew feature or requestNew feature or request
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
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request