Re: Adding an @Immutable annotation to Java

2021-11-30 Thread Brian Goetz
I don’t see how a restricted reference by itself is useful, if you cannot depend upon the object not being mutated via other references. Agree; this may help you do local proofs of correctness, and may conceivably help the JIT (though, its pretty smart about figuring this stuff out on its own),

Re: Adding an @Immutable annotation to Java

2021-11-29 Thread Alan Snyder
> On Nov 29, 2021, at 10:42 AM, Simon Roberts > wrote: > > I will say that as Java provides more and more features modeled on more > functional languages, I'm finding more and more people struggling with the > inherently mutable nature of Java, and that I strongly believe that > something that

Re: Adding an @Immutable annotation to Java

2021-11-29 Thread Simon Roberts
t; github.com > > > De: Alberto Otero Rodríguez > Enviado: jueves, 25 de noviembre de 2021 9:39 > Para: Justin Dekeyser > Cc: core-libs-dev@openjdk.java.net > Asunto: RE: Adding an @Immutable annotation to Java > > I have not thought about

RE: Adding an @Immutable annotation to Java

2021-11-29 Thread Alberto Otero Rodríguez
. github.com De: Alberto Otero Rodríguez Enviado: jueves, 25 de noviembre de 2021 9:39 Para: Justin Dekeyser Cc: core-libs-dev@openjdk.java.net Asunto: RE: Adding an @Immutable annotation to Java I have not thought about that. I'm not a Java expert. I just throwed the idea precise

Re: Adding an @Immutable annotation to Java

2021-11-26 Thread Rob Spoor
If this is really something that's desired, then why use an annotation when there's a keyword already available: const. However, there's a reason that's never been actually used in Java, and that's because it's so hard to get right. On 26/11/2021 00:11, Alan Snyder wrote: I like the idea of

Re: Adding an @Immutable annotation to Java

2021-11-25 Thread Alan Snyder
I like the idea of an @Immutable annotation. So much so, that I have created one and use it heavily. However, my @Immutable is just for documentation; it does not have a rigorous semantics that would be needed for a compiler to validate its use or generate different code. But it could be used by

Re: Adding an @Immutable annotation to Java

2021-11-25 Thread Ralph Goers
I would think that if a class is marked immutable that would imply all the fields in it and from its inherited classes should be immutable. If fields are marked immutable then it would only apply to them. What I wonder is what its relationship to final would be. The final annotation implies th

Re: Adding an @Immutable annotation to Java

2021-11-25 Thread Andrew Haley
On 11/25/21 08:27, Justin Dekeyser wrote: Quick question, out of curiosity: how would it behave with respect to inheritance? Can a @Immutable class inherit from an non immutable one? And: does @Immutable mean deeply immutable? IMO it really should, but that's harder to check, and we'd have to

RE: Adding an @Immutable annotation to Java

2021-11-25 Thread Alberto Otero Rodríguez
Enviado: jueves, 25 de noviembre de 2021 9:27 Para: Alberto Otero Rodríguez Cc: core-libs-dev@openjdk.java.net Asunto: Re: Adding an @Immutable annotation to Java Hello, Quick question, out of curiosity: how would it behave with respect to inheritance? Can a @Immutable class inherit from an non im

Re: Adding an @Immutable annotation to Java

2021-11-25 Thread Justin Dekeyser
Hello, Quick question, out of curiosity: how would it behave with respect to inheritance? Can a @Immutable class inherit from an non immutable one? if no: that's a bit annoying, no? (fake immutability) Can @Immutable class be subclassed to a non @Immutable one? if no: that's a bit annoying too, no