From: Andreas R. <ros...@ps...> - 2001-10-11 17:04:33
|
Stephen Weeks wrote: > > I would be interested to hear if and an explanation of why the > Definition requires any of these examples to succeed. My reading is that the Definition requires all of these examples to elaborate: in all cases the "program context uniquely determines the labels of the fields to be matched". The amount of "program context" is not restricted in the text. But that is clearly a "bug" IMHO. Even for local declarations you will have a very hard time implementing it without going almost all the way to full polymorphic record typing. When you generalise, you have to know the set of labels to determine what free type variables there are. I suppose what Mosml and the Kit do is just to assume none, i.e. the flexible part has to be monomorphic. This way they can type 2 and 3, but not 4, which seems rather ad-hoc. Thus the only clean rule I can think of that avoids polymorphic record typing is restricting the "program context" to the innermost enclosing value declaration, consistently invalidating all 3 examples. BTW, Alice can type 2, but not 3 and 4 - it assumes that the flexible part is empty. Cannot check MLWorks right now. > (* flexrecord2 *) > val _ = > let > val g = #foo > val _ = g {foo = 13} > val _ = g {foo = "yes"} > in > () > end > (* flexrecord2 *) > > (* flexrecord3 *) > val _ = > let > val g = #foo > val _ = g {foo = 13, goo = 1.0} > val _ = g {foo = "yes", goo = 1.0} > in > () > end > (* flexrecord3 *) > > (* flexrecord4 *) > val _ = > let > val g = #foo > val _ = g {foo = 13, goo = 1.0} > val _ = g {foo = "yes", goo = false} > in > () > end > (* flexrecord4 *) |