On 15 July 2010 08:31, Patrick Wright <[email protected]> wrote: >> Immutable is hard-coded into the type system. A class is declared as >> immutable using a keyword (const). Lists, maps and functions can be >> converted to immutable (and will do so automatically by the compiler). > > The problem with using a marker/keyword for immutability is that as > soon as you touch a class outside of your own type system, which > itself is not so marked, you have no (easy) way to tell if it is also > immutable; that's a general problem, as far as I know. How does > Phantom handle interaction with the huge number of non-immutable > classes out there in the wild in all those useful JVM libraries?
Agreed. Two parts to the response. Firstly, Fantom has a focus on providing a set of libraries of its own beyond those of the JDK (fresh start, less cruft). This provides Fantom with more of a new platform feel, and obviously means thatcore coding doesn't need JVM libraries. Of course, it is possible to fully interoperate with the JDK classes (using and extending/implementing), and key classes are directly known to the compiler, like Integer/Float etc. Secondly, it may well be possible to use the JCIP Immutable annotation - http://www.javaconcurrencyinpractice.com/annotations/doc/net/jcip/annotations/package-summary.html - to pickup immutability. Or possibly, infer it by bytecode analysis. This isn't in Fantom now, but could be added. Interestingly, there is a similar problem with null-handling, as the Fantom type system knows whether a variable is null-or-not, but the JDK classes don't. Here I know that JSR-305 has a database of JDK methods and their null-handling behaviour. http://fantom.org/doc/docLang/TypeSystem.html#nullableTypes Stephen -- You received this message because you are subscribed to the Google Groups "JVM Languages" 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/jvm-languages?hl=en.
