String and opBinary

Eyyub eyyub.pangearaion at gmail.com
Fri Jun 1 14:57:15 PDT 2012


On Friday, 1 June 2012 at 21:26:55 UTC, Jonathan M Davis wrote:
> On Friday, June 01, 2012 22:18:50 Eyyub wrote:
>> Why doesn't D allow a way to write operator overloading at
>> scope-module level like in C++ ?(in this case)
>
> Why would you need to? It only works when defining them for 
> user-defined types
> anyway. So, having them be member functions makes perfect 
> sense. And
> opBinaryRight solves the problem of needing the overload where 
> the other type
> is on the left rather than the one that you're defining the 
> overloaded operator
> for, which is the typical reason to define an overloaded 
> operator as a friend
> function rather than a member function in C++.
>
> - Jonathan M Davis

Hi,

I asked this question just for know if there are a reason about
this choice.

Anyway, want to multiply a string by a string is a non-sense. :P

Thanks,


More information about the Digitalmars-d-learn mailing list