Should we add `a * b` for vectors?

Manu turkeyman at gmail.com
Wed Sep 27 23:25:34 UTC 2017


On 27 September 2017 at 22:01, jmh530 via Digitalmars-d <
digitalmars-d at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20170928/3a34f612/attachment.html>


More information about the Digitalmars-d mailing list