On 28 Sep 2010, at 18:00, Eliot Miranda wrote:

> I think it's orthogonal to immutability.  Non-immutable literals are "just 
> plain wrong" (actually unsafe).  The optimization is confusing and unexpected 
> to the inexperienced.  But I emphatically agree with the last part; it's not 
> a particularly useful optimization.

Of course, you are right: non-immutable literals are unsafe. 
However, when you know what you are doing and you are 'mutating' a literal in 
your code, I think it's surprising that the mutation also happens to what seems 
to be another literal in the same code (because they are written in different 
locations in the same method body), just because they happen to be equal.

Admittedly, it's not a common issue and mutating literals might sound like 
dirty code (it probably is in 99% of the cases) but the flexibility also 
enables powerful things. I have, for example, used that in the implementation 
of the compiled methods for proxy java classes in JavaConnect.

Anyway, I appreciate the discussion!

Johan
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to