Method names for Valhalla value types
David Alayachew
davidalayachew at gmail.com
Wed Sep 10 17:26:56 UTC 2025
I'm also in camp 2. I prefer the past tense style, for the logic explained
via sort() vs sorted().
On Wed, Sep 10, 2025, 12:31 PM Chen Liang <chen.l.liang at oracle.com> wrote:
> 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 <valhalla-dev-retn at openjdk.org> on behalf of Pedro
> Lamarão <pedro.lamarao at prodist.com.br>
> *Sent:* Wednesday, September 10, 2025 11:11 AM
> *To:* Stephen Colebourne <scolebourne at joda.org>
> *Cc:* valhalla-dev <valhalla-dev at openjdk.java.net>
> *Subject:* Re: Method names for Valhalla value types
>
> 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/0d1064ed/attachment-0001.htm>
More information about the valhalla-dev
mailing list