What happened to the "mutable struct" debate?

Rezaei, Mohammad A. Mohammad.Rezaei at gs.com
Fri Jan 23 15:11:36 UTC 2015


I disagree with this linguistic characterization. There is no such thing as a "cell" in the JLS. There are only two things defined there:
1) Primitive Value (per JLS 4.2)
2) Variable of Primitive Type (per JLS 4.12.1)

In any reasonable English interpretation, and in common usage, both are just called "primitive".

Said differently, the answer to the question "given the statement 'int x;', is x a primitive?" would be "yes".

So the question "are primitives mutable?" must address both (1) and (2). The only logically consistent interpretation here is :
1) Primitive Values are immutable.
2) Variables of Primitive type are mutable (except when declared final).
3) Primitives (meaning either (1) or (2)) is therefore mutable.

Brian's language uses "int" instead of "primitive". I would suggest asking the question "given the statement 'int x;' is x an int?" If the answer is "no", something has gone horribly wrong. A very good answer would be "yes, x is variable of int type", which fixes the linguistic ambiguity of "int".

Thanks
Moh

>-----Original Message-----
>From: valhalla-dev [mailto:valhalla-dev-bounces at openjdk.java.net] On Behalf Of
>Brian Goetz
>Sent: Thursday, January 22, 2015 11:43 PM
>To: Andrew Purtell; valhalla-dev at openjdk.java.net
>Subject: Re: What happened to the "mutable struct" debate?
>
>> Stating the obvious, from a newcomer's perspective, ints are mutable.
>
>Except they're not :(
>
>ints are immutable; you can't change the value 3.  Two threes are the
>same int, regardless of where they are stored.  You can have a *mutable*
>cell that holds an int; similarly, you can have a mutable cell that
>holds a value.



More information about the valhalla-dev mailing list