I agree an adjective or a noun method name to indicate a derived distinct 
object is better. Such pattern is seen in some wrapper class methods, like 
Integer.lowestOneBit. A verb name like "add" works better for static methods 
that take two BigDecimal. Since Brian is talking about type classes in this 
JVMLS, I would assume the verb names like "add" would be more suitable for the 
type classes than on the numeric types themselves.

Chen
________________________________
From: valhalla-dev <[email protected]> on behalf of Pedro Lamarão 
<[email protected]>
Sent: Wednesday, September 10, 2025 11:11 AM
To: Stephen Colebourne <[email protected]>
Cc: valhalla-dev <[email protected]>
Subject: Re: Method names for Valhalla value types

Em qua., 10 de set. de 2025 às 11:54, Stephen Colebourne 
<[email protected]<mailto:[email protected]>> escreveu:

1) Basic - add/subtract/multiply/divide/negate
Used by BigDecimal/BigInteger

To me, style 1 communicates "update" -- x.add(y) -- add y to x, update x by 
adding y.
It would confuse me if "add" did not update x.
Following Stepanov in "Elements of Programming", I think of this as 
"accumulator style".

For immutable data types, I think style 2 communicates "new value".
In my own arithmetic code, I use sum, difference, product, quotient and 
remainder; division produces a pair; inverse, half, twice or double etc.

--
Pedro Lamarão

Reply via email to