On Tue, Oct 12, 2010 at 10:22 AM, Kevin Wright <[email protected]>wrote:
> > > Immutability: >> >> Actually, immutability is complicated. For example, java.io.File seems >> immutable for all intents and purposes, and has some of the practical >> properties of immutables (such as: cloning a File object is pointless, >> as is making a defensive copy), and certainly looks like one (only >> final fields, and the class is even final itself), and you can even >> share them between threads without synchronization, but nevertheless >> it clearly looks like a mutable: Something like .mkdir() or .delete() >> changes some state (it's just not state in the object that you're >> changing!), and something like .isFile() is not predictable (i.e. it >> can change over time, which is a property of mutables). > > > You're mixing up concepts here, taking the simple thing (immutability) and > declaring it to be complicated because it's associated with another thing > that truly *is* complicated (the Java standard I/O APIs). > > Immutability is simple. The Ace of spades is immutable, it will always > continue to be the Ace of Spades into eternity. The same goes for April > 12th 1942, or for the concept of "the file located at c:/autoxec.bat". > Simple unchangeable concepts that can be readily passed around in the sure > knowledge that they'll never magically become something else. > > Attempting to define anannotation that the compiler can somehow verify is dumb because immutability is concept that exists at higher level that a compiler can never fully appreicate or understand. At best immutability can only be a tag rather than actual verifiable construct. Imjutability is more than just having all fields being final, in the end when one gets away from more toy examples what exactly can it verify. If you want to document something as immutable then write some real javadoc. Personally i think all these discussions are kind of pointless, when we would do better if people just spent the time writing up some proper javadoc. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
