On 27 September 2017 at 22:01, jmh530 via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
> On Wednesday, 27 September 2017 at 07:41:23 UTC, Ilya Yaroshenko wrote: > >> >> I would prefer outer operator overloading be added to D instead of type >> wrappers. So a user can import a library for operations, rather then >> library of wrappers. --Ilya >> > > This might be a step in the right direction. It doesn't need to be > full-blown extension methods/partial classes. Just the ability to treat > operator overloading like free-standing functions (with power of UFCS). > Something like: > > struct Foo > { > int data; > } > > Foo opBinary!(string op)(Foo x, Foo y) > { > return mixin("x.data" ~ op ~ "y.data"); > } > > That would mean you could also do something like: > import lubeck : opBinary; > Again, sadly, D has no ADL, and this will be an unmitigated disaster as a result! Instantiations of templates will use the default elementwise operator instead of the one you specified in your module, and nobody will understand why.