caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* mutable and polymorphism
@ 2010-09-15 17:10 Radu Grigore
  2010-09-15 17:40 ` [Caml-list] " Andreas Rossberg
  2010-09-17 14:04 ` Radu Grigore
  0 siblings, 2 replies; 9+ messages in thread
From: Radu Grigore @ 2010-09-15 17:10 UTC (permalink / raw)
  To: caml-list

Compile the following three files one-by-one.
  (*a.ml*) let _ = ref () in let f = fun _ -> () in f 1; f 'a'
  (*b.ml*) let f = let _ = () in fun _ -> () in f 1; f 'a'
  (*c.ml*) let f = let _ = ref () in fun _ -> () in f 1; f 'a'
The files a.ml and b.ml compile; the file c.ml fails with
  Error: This expression has type char
    but an expression was expected of type int
Could someone explain why having a mutable field ("contents" in this
case) restricts the polymorphism of f?

PS: A few hours ago I tried to post from Google Groups, but the
message didn't seem to go thru. Apologies if this is a duplicate


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-09-17 14:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-15 17:10 mutable and polymorphism Radu Grigore
2010-09-15 17:40 ` [Caml-list] " Andreas Rossberg
2010-09-15 17:59   ` Radu Grigore
2010-09-15 19:10     ` Goswin von Brederlow
2010-09-15 19:38       ` Radu Grigore
2010-09-15 20:44         ` Kaustuv Chaudhuri
2010-09-17  7:31         ` Goswin von Brederlow
2010-09-17 14:04 ` Radu Grigore
2010-09-17 14:08   ` Radu Grigore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).