On Saturday, 20 January 2024 at 17:47:29 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Not really any other way to do it, create context (i.e. struct,
or stack) and have a delegate point to both it and a patch
function.
It'll be how partial is implemented.
https://dlang.org/phobos/std_functional.html#.partial
Hi Rikki,
thanks for the link to partial. I tried this:
```d
import std.stdio;
// Overloads are resolved when the partially applied function
is called
// with the remaining arguments.
struct S
{
static char fun(int i, string s) { return s[i]; }
static int fun(int a, int b) { return a * b; }
}
void main()
{
alias fun3 = partial!(S.fun, 3);
writeln(fun3("hello")); // 'l'
writeln(fun3(10)); // 30
}
```
But getting:
```
partial.d:12:14: error: template instance partial!(S.fun, 3)
partial is not a template declaration, it is a module
alias fun3 = partial!(S.fun, 3);
```