Re: Compile delegate with enum into proper function?

2022-05-08 Thread jmh530 via Digitalmars-d-learn
On Sunday, 8 May 2022 at 03:58:06 UTC, Tejas wrote: [snip] If there is only one possible value for the overload, is there an issue with using default arguments? [snip] Default arguments are intended to be resolved at runtime. That is, if you compile a function with two parameters and one

Re: What am I doing wrong here?

2022-05-08 Thread JG via Digitalmars-d-learn
On Saturday, 7 May 2022 at 02:29:59 UTC, Salih Dincer wrote: On Friday, 6 May 2022 at 18:04:13 UTC, JG wrote: ```d //... struct Adder { int a; int opCall(int b) { return a+b; } } auto adder(int a) { auto ret = Adder.init; ret.a=a; return ret; } void main() { auto g =

Re: Compile delegate with enum into proper function?

2022-05-08 Thread Tejas via Digitalmars-d-learn
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. It would be

Re: Compile delegate with enum into proper function?

2022-05-08 Thread Salih Dincer via Digitalmars-d-learn
Either we didn't understand the question, or this is not what you're talking about: On Sunday, 8 May 2022 at 03:58:06 UTC, Tejas wrote: 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; }