www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [ot] Scala gets a system for tracking immutability

reply tim <tim ber.net> writes:
So now D isn't the only OOP language with an immutability system:

"In the course of a semester project, Davide Galimberti (EPFL student) recently
implemented a prototype of the Javari [1] system as a Scala compiler plugin.

The system not only allows to check whether a class is immutable, it also
allows tracking immutable references (aliases) to potentially mutable objects.
It guarantees that no state modifications are performed through an immutable
reference."

http://permalink.gmane.org/gmane.comp.lang.scala.debate/4352
Mar 12 2010
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
tim:
 So now D isn't the only OOP language with an immutability system:

This page: http://old.nabble.com/Could-proved-immutable-classes-be-added-to-Scala--td14626792.html Says:
* Any class that extends an immutable class must be immutable

This seems true in D too: immutable class Foo { int x; this(int xx) { this.x = xx; } } class Bar : Foo { int y; this(int xx, int yy) { super(xx); this.y = yy; } } void main() { auto b = new Bar(1, 2); b.y = 10; // Error } But you can omit the immutable annotation in Bar, so nowhere it's written that y too is immutable. I think this is bad, worth fixing (Bar or y have to be annotated with immutable). Bye, bearophile
Mar 12 2010
prev sibling parent =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
On 03/12/2010 07:18 PM, tim wrote:
 The system not only allows to check whether a class is immutable, it also
allows tracking immutable references (aliases) to potentially mutable objects.
It guarantees that no state modifications are performed through an immutable
reference."

Wouldn't that be equivalent to const, not immutable?
Mar 12 2010