Re: combination problem solved with Mathematica
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: combination problem solved with Mathematica
- From: ark at research.att.com
- Date: Mon, 30 Mar 92 09:35:32 EST
Whether or not it is an advantage to use a language that is "not limited by datatype" is something about which reasonable people can disagree. It is certainly true that once in a while, the ML type system gets in one's way, as it did in this case. It would actually be quite nice to have a function that can behave in any of the following ways: unit -> unit 'a list -> 'a list 'a list * 'b list -> ('a * 'b) list 'a list * 'b list * 'c list -> ('a * 'b * 'c) list and so on. Unfortunately, that kind of polymorphism is simply not part of the ML type system. That's life. The reason that reasonable people can disagree about the importance of this is twofold: 1. As I showed in my example, I can come close to achieving what I want by using lists, in which case the type of the function is 'a list list -> 'a list list If I have a collection of diverse types, I can bundle them up into one with a `datatype' declaration and then pick them apart later. Thus although I can't get exactly what I wanted, I can come close enough for most practical purposes. 2. Strong typing has two considerable compensating advantages. First, typechecking often finds my mistakes for me before I actually run my program. Second, it often allows for much more efficient code generation in those cases where the compiler can use its knowledge of types to figure out much better machine code to generate for programs. Finally, I should note that comparing programming languages is a tricky business, especially when you include standard library functions. The trouble is that a good library can radically alter the character of a language, and is it often true that the language and library were designed by different (groups of) people entirely.