
Jean-Phillipe Bernardy wrote:
... For example, Data.Set is "monomorphic", but still an abstract data type (one cannot observe the internal structure, and indeed we are considering changing it)
but I cannot easily choose another representation because I would have to change my program (replace Set by AVLSet or something) everywhere. I sometimes (reluctantly) use a detour by declaring a wrapper type http://141.57.11.163/cgi-bin/cvsweb/lib/Autolib/FiniteMap.hs?rev=1.12 but this is an ugly workaround and the root of the problem is that there is no defined interface for Set implementations. Cale Gibbard wrote:
[in Java] classes implement some interfaces, but only one interface at a time can be mentioned when it comes to using them.
Right. Although you can always write "interface A extends B, C {}" and then use A for "B and C". But I agree that this is inconvenient.
interfaces in Java are not permitted to provide default implementations of methods which they declare
If you want that, then you want an "abstract class", e. g. http://java.sun.com/j2se/1.5.0/docs/api/java/util/AbstractSet.html I think the sole purpose of an interface is to specify a contract. Obviously the Java design choice was to not mix this with providing help when fulfilling the contract. Best regards, -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- ---- http://www.imn.htwk-leipzig.de/~waldmann/ -------