D needs to get its shit together!

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 12:45:41 PDT 2017


On Wednesday, 21 June 2017 at 18:35:33 UTC, data pulverizer wrote:
> On Monday, 19 June 2017 at 12:46:19 UTC, jmh530 wrote:
>> I just hope that we can get some operator overloading so that 
>> I don't have to write mtimes all over the place. My ideal 
>> would be a DIP that adds the option to overload opBinary for 
>> \, .+, .-, .*, ./. Lubeck could use \ for inverse, .+ etc. for 
>> element-wise matrix operations, and * for mtimes, etc. Very 
>> Matlab-like.

I double-checked and noticed that Matlab doesn't actually have 
.+/.-, just +/-. Since D's a[] + b[] doesn't seem all that 
different from Matlab's a + b, with the restriction that there 
needs to be destination memory, it seems like it would be a 
confusing to add in another way of doing things. So maybe just 
add \ and another operator for matrix multiplication. I don't 
really know.

>
> I'd like to second more flexibility around unary and binary 
> operators, perhaps we can have another keyword for instance 
> "record" that is essentially a D struct but allows the user to 
> specify their own operators - it could be included unofficially 
> at first without impacting the rest of the D language with the 
> stipulation that it is not used in D's core libraries or in 
> anything important. This functionality would allow notation 
> native to different fields in analysis to be used.

An interesting idea, but I don't know if they would go to for it.

If you want more operator overloading on a class, you could put 
the class as a member of the "record" and alias this it?


More information about the Digitalmars-d mailing list