From: Peter S. <se...@di...> - 2001-09-26 20:46:45
|
On Wed, 26 Sep 2001, Andrew Kennedy wrote: > (1) What does one do about types that are still "undetermined" > at the level of the unit-of-compilation (e.g. "..." or "SIG" > above do not resolve the type of "settings"). Instantiating > with something arbitrary (e.g. unit) is just too confusing so > I would vote for rejecting such programs as ambiguous. I agree with that and believe that the compilation should be rejected; separately compiled entities with free ("undetermined") type variables raise unpleasant questions about their propagation (and possibly distinct instantiations, yrk) when compiling other compilation units. Moscow ML rejects free top-level type variables in compilation units. > (2) What does one do in a top-level-loop environment? Here it makes sense to accept free top-level type variables as in OCaml and Moscow ML. The latter system issues a warning, and the type report shows the list of universally quantified type variables (the 'b in the type of i2): - val i1 = rev o rev; ! Warning: Value polymorphism: ! Free type variable(s) at top level in value identifier i1 > val i1 = fn : 'a list -> 'a list - val i2 = fn xs => (rev o rev) xs; > val 'b i2 = fn : 'b list -> 'b list However, it is confusing (and probably a mistake) that Moscow ML currently accepts free type variables in structure declarations in the interactive system: - structure S = struct val i = rev o rev end; ! Warning: Value polymorphism: ! Free type variable(s) at top level in structure identifier S > structure S : {val i : 'b list -> 'b list} Note that 'b in the type of S.i is not universally quantified. The question of how much context to take into account has existed for years, namely, when resolving operator overloading and flex records. The Definition only specifies that at most the enclosing structure-level declaration should be taken into account. Also in this respect Moscow ML and SML/NJ differ somewhat, but this very rarely matters in practice. Peter -- Department of Mathematics and Physics * http://www.dina.kvl.dk/~sestoft/ Royal Veterinary and Agricultural University * Tel +45 3528 2334 Thorvaldsensvej 40, DK-1871 Frederiksberg C, Denmark * Fax +45 3528 2350 |