
dpt@lotus.bostoncoop.net (Dylan Thurston) writes:
On Mon, Feb 28, 2005 at 01:45:25PM +0000, Malcolm Wallace wrote:
As examples of language features that should be removed or revised, how about these: (a) n+k patterns (b) the defaulting mechanism (c) the monomorphism restriction
(b) is annoying, but I don't see an alternative now. Removing the defaulting mechanism would be very backwards-incompatible, and require a lot of type signatures in annoying places.
Yes, I was thinking more of revision than removal here. The main problem with the current defaulting mechanism is that it is arbitrarily limited to certain classes. A better design would be more orthogonal, for instance allowing the programmer to define a lattice of class/type pairs to use as defaults. e.g. default Num Integer default Floating Double default Monad Maybe default Codec.Compressable Codec.Compress.Bzip Where the usage of a class method is ambiguous, the compiler would choose the least member of the lattice that satisfies all the superclass constraints. To make the design truly orthogonal however, it would probably be necessary to remove the "default" default of (Integer,Double), and instead perhaps allow default clauses to be exported/imported explicitly. I think something like this could be pretty-much backward compatible, as the semantics are very close to the current semantics (Report section 4.3.3), but without the restriction that Num be a superclass of the defaulted type. The revised Prelude would simply export the Num=Integer, Floating=Double default bindings, and the minor change of syntax elsewhere would be manageable. Regards, Malcolm