On Sunday, 8 May 2022 at 01:38:55 UTC, jmh530 wrote:
On Saturday, 7 May 2022 at 23:30:37 UTC, Paul Backus wrote:
[snip]

Worth noting that you *can* write

```d
alias foo = partial!(foo, a);
```

...which will add the partially-applied version to `foo`'s overload set.

You sure about that? Below fails to compile on godbolt with ldc 1.27.1 [1]. For some reason run.dlang.org is just hanging...

```d
import core.stdc.stdio: printf;
import std: partial;

int foo(int x, int a) {
        return x + a;
}
enum int a = 2;

alias foo = partial!(foo, a);

void main() {
    int x = 2;
    int y = foo(x, a);
    printf("the value of y is %i", y);
    auto z = foo(x);
    printf("the value of z is %i", z);
}
```

[1] https://d.godbolt.org/z/dx8aWfjYW

If there is only one possible value for the overload, is there an issue with using default arguments?

```d
int foo(int x, int a = 1) {
    return x + a;
}

void main()
{
    import std.stdio:writeln;

    writeln(foo(5));
    writeln(foo(6, 7));
}

```

Reply via email to