Operator overloading
Remi Forax
forax at univ-mlv.fr
Fri Sep 5 21:03:37 UTC 2014
On 09/05/2014 09:22 PM, David Chase wrote:
> Remi, I can’t speak for him, but supposing the libraries for Arrays 2.0 turn out okay or better (it’s possible).
> Do you prefer
>
> a.set(times(plus(b,c),d)
>
> or
>
> a := (b+c)*d
>
> ?
>
> I put in “:=“ because I think overloading = might not work, since it already has a defined meaning for all object types.
>
> And the “before” syntax might be a lot clunkier than that, what if it is
>
> a.set(times.apply(plus.apply(b,c),d) ?
>
> David
Hi David,
There are a lot of hazards associated with user defined operator
overloading:
- already existing operators use implicit conversions,
I don't want user defined implicit conversions in Java.
- operator are functions, not method
I don't want virtual dispatch on operators in Java.
- already existing operators have a default precedence and
associativity for the parser
I don't want user defined precedence rules in Java.
- already existing operators are defined on immutable values
I don't want rules about aliases and intermediary objects a la C++
in Java.
if you solve all these issues you have my vote.
Rémi
>
> On 2014-09-05, at 3:11 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>
>> On 09/05/2014 07:32 PM, Fabrizio Parini wrote:
>>> Hi,
>>>
>>> I would like to ask if there are good chances that Java will support operator overloading for value types when they become available.
>>>
>>> Regards,
>>> Fabrizio
>> which kind and why ?
>>
>> Rémi
>>
More information about the valhalla-dev
mailing list