Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 12 December 2020 at 20:25:48 UTC, Adam D. Ruppe wrote: On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. It is useful in several other contexts though, including user o

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 20:26:00 UTC, Dennis wrote: If issue 19365 got fixed eeek I thought that was fixed but apparently not :( so yeah alias won't work for operator overloads. Does work for other functions so good technique to know but not here. So for op prolly go with the strin

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. It is useful in several other contexts though, including user overriding and private data stores for the mixin. The easiest workar

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Dennis via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. The easiest workaround is to use string mixins instead, which work the way you'd expect them to. If issue 19365 got fixed, it could

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: Functions from different mixin templates can't overload each other. The reason for this is that, when you mix in a mixin template, it does not *actually* add the declarations inside it to a current scope: instead, it adds them to

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 12 December 2020 at 17:36:57 UTC, Tobias Pankrath wrote: I want to wrap e.g. an int and implement basic arithmetic. In the provided example [1] I use two mixin templates to separately implement scaling (multiplication with int/double) and addition and subtraction with the type its

Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
I want to wrap e.g. an int and implement basic arithmetic. In the provided example [1] I use two mixin templates to separately implement scaling (multiplication with int/double) and addition and subtraction with the type itself. In the end I want to have several distinct wrappers and allow s