On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote:
In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there should be a way to specify it at compile-time.

Have you tried [`std.functional.partial`][1]? Using it, your example could be written like this:

```d
import std.functional: partial;

enum int a = 1;
alias foo2 = partial!(foo, a);
```

Or, if `a` absolutely has to be the second argument, you can combine it with [`std.functional.reverseArgs`][2]:

```d
import std.functional: partial, reverseArgs;

enum int a = 1;
alias foo2 = partial!(reverseArgs!foo, a);
```

[1]: https://phobos.dpldocs.info/std.functional.partial.html
[2]: https://phobos.dpldocs.info/std.functional.reverseArgs.html

Reply via email to