Method names for Valhalla value types

Pedro Lamarão pedro.lamarao at prodist.com.br
Wed Sep 10 16:11:04 UTC 2025


Em qua., 10 de set. de 2025 às 11:54, Stephen Colebourne <
scolebourne at joda.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20250910/4d7ea76a/attachment.htm>


More information about the valhalla-dev mailing list