Re: No need opUnary

2022-12-19 Thread Ali Çehreli via Digitalmars-d-learn
erator overload for usages like 'obj += 42'. */ @property opOpAssign(string op)(int x) { write(":"); // came here before mixin("return value"~op~"=x;"); } // no need: opUnary(string op)(); } void main() { /* Ok, this is regular ob

Re: No need opUnary

2022-12-19 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 19 December 2022 at 07:32:02 UTC, j wrote: Was my email deleted? Which compiler are you using? Are you an AI engine? SDB@79

Re: No need opUnary

2022-12-18 Thread j via Digitalmars-d-learn
On Monday, 19 December 2022 at 04:26:39 UTC, Salih Dincer wrote: On Sunday, 18 December 2022 at 21:17:02 UTC, j wrote: Why are you using `@property` everywhere? You are right but if I don't use it for `opCall()` the output will be like `S(9)`. Likewise, if I don't use `inout`, the program

Re: No need opUnary

2022-12-18 Thread j via Digitalmars-d-learn
On Monday, 19 December 2022 at 04:26:39 UTC, Salih Dincer wrote: On Sunday, 18 December 2022 at 21:17:02 UTC, j wrote: Why are you using `@property` everywhere? You are right but if I don't use it for `opCall()` the output will be like `S(9)`. Likewise, if I don't use `inout`, the program

Re: No need opUnary

2022-12-18 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 18 December 2022 at 21:17:02 UTC, j wrote: Why are you using `@property` everywhere? You are right but if I don't use it for `opCall()` the output will be like `S(9)`. Likewise, if I don't use `inout`, the program is terminated. I think it's a bug with `std.format` that I said

Re: No need opUnary

2022-12-18 Thread j via Digitalmars-d-learn
opCall(int x) { return value = x; } @property opCall() inout { return value; } @property opOpAssign(string op)(int x) { write(":"); // came here before mixin("return value"~op~"=x;"); } // no need: opUnary(string op)(); } void main()

No need opUnary

2022-12-18 Thread Salih Dincer via Digitalmars-d-learn
() inout { return value; } @property opOpAssign(string op)(int x) { write(":"); // came here before mixin("return value"~op~"=x;"); } // no need: opUnary(string op)(); } void main() { S a = S(10), b = S(-1); writeln(a + b); // 9 write