caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Magic with fun (type t) ... ?
@ 2011-01-26 22:17 Jim Pryor
  2011-01-26 22:33 ` David Allsopp
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jim Pryor @ 2011-01-26 22:17 UTC (permalink / raw)
  To: caml-list

I expect this is bad coding style, and should not be relied on. However,
I was surprised at the behavior, and wondered whether it was intended:

# let f = fun (type t) x ->
    let module M = struct exception E of t end in
    M.E x;;
val f : 'a -> exn = <fun>

f is polymorphic, as we expect:

# f 1;;
- : exn = E 1
# f "s";;
- : exn = E "s"

But now notice:

# f ();;
- : exn = E 0
# f None;;
- : exn = E 0

It appears that non-heap values are always getting magicked into ints.

Has this been noted before?

-- 
Jim Pryor
profjimm@jimpryor.net

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

end of thread, other threads:[~2011-01-27 23:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 22:17 [Caml-list] Magic with fun (type t) ... ? Jim Pryor
2011-01-26 22:33 ` David Allsopp
2011-01-27  6:13   ` Alain Frisch
2011-01-27 23:56     ` Guillaume Yziquel
2011-01-26 22:34 ` Jim Pryor
2011-01-26 23:07 ` Guillaume Yziquel
2011-01-26 23:11 ` Gabriel Scherer

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).