Operator overloading for collections?
david Grajales
david.1993grajales at gmail.com
Fri Aug 22 20:36:26 UTC 2025
for my understanding it could refer to adding a single element to a list
var list = List[1, 2, 3];
var expandedList = list + 3 // [1, 2, 3, 3] this would not be allowed
But arithmetic operations between concrete data structures seems more
likely since intersection, difference, inclusión and exclusion have
mathematical meaning, also it would allow for expressive libraries for
linear algebra (very used in science and engineering for signal processing
for example)
Not allowing for operator overloading ****between**** data structures would
be a huge loss IMHO. Java is already lagging behind not having built-in
complex and unsigned numeric types. These Type classes would allow Java to
close the gap very quickly.
But this is all speculative, not having
Best regards
El jue, 21 ago 2025 a la(s) 10:18 p.m., David Alayachew (
davidalayachew at gmail.com) escribió:
> Didn't the talk shoot this exact idea down? At 53:45 on the video --
> youtu.be/Gz7Or9C0TpM
>
> I am still watching the recording now, so maybe he approves it later.
>
> On Thu, Aug 21, 2025, 7:02 PM david Grajales <david.1993grajales at gmail.com>
> wrote:
>
>> Dear Amber team,
>>
>> I hope this message finds you well.
>>
>> I recently watched Brian’s talk "Growing the java language" and I
>> found the discussion on operator overloading particularly interesting. I
>> appreciated how the proposed approach allows operator overloading in a more
>> restricted and safer way, by enforcing algebraic laws.
>>
>> This immediately made me think about potential use cases for
>> collections—for example, using operators for union (+), difference (-),
>> exclusion, and similar operations. However, since this feature is intended
>> to be limited to value classes, and the current collection classes are not
>> value-based, it seems they would not benefit from these new operator
>> overloading capabilities.
>>
>> My question is: are there any plans to enhance the collections framework
>> with value-class-based variants, so that they could take advantage of this
>> feature? Or is this idea (or any other related to the use case) not
>> currently under consideration?
>>
>> I know this is still under discussion, I am just curious about this
>> particular use case.
>>
>> Thank you very much for your work and for your time.
>>
>> Best regards, and always yours.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20250822/cef39d88/attachment.htm>
More information about the amber-dev
mailing list