<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/01/3597c0d55acb8b0cfc394f624453ba49"
  from="Julien SIGNOLES &lt;julien.signoles@c...&gt;"
  author="Julien SIGNOLES"
  date="2009-01-22T14:37:53"
  subject="Marshal.to_string and closures"
  prev="2009/01/233b0823ddc93b99900d055dfa8ab3ae"
  next="2009/01/a8e2aeb057222710dd188876f1b96cc8"
  prev-thread="2009/01/233b0823ddc93b99900d055dfa8ab3ae"
  next-thread="2009/01/f6735e5adf3e71e22f286197791245f5"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Marshal.to_string and closures">
<msg 
  url="2009/01/3597c0d55acb8b0cfc394f624453ba49"
  from="Julien SIGNOLES &lt;julien.signoles@c...&gt;"
  author="Julien SIGNOLES"
  date="2009-01-22T14:37:53"
  subject="Marshal.to_string and closures">
</msg>
</thread>

<contents>
Hello,

I have a not-so-easy-to-reproduce case in which
=====
let tbl = Hashtbl.create 7
let f x = Hashtbl.find tbl x
let g b = Marshal.to_string (fun _ -&gt; f b) [ Marshal.Closures ]
...
let _ = g ...
=====
may raise the exception
=====
Fatal error: exception Invalid_argument("output_value: abstract value
(Abstract)").
=====

If I wrote the above code like below, all is fine:
=====
let tbl = Hashtbl.create 7
let f x = Hashtbl.find tbl x;;
let g b = 
  let y = f b in
  Marshal.to_string (fun _ -&gt; y) [ Marshal.Closures ]
...
let _ = g ...
=====

After debugging, that is the marshalling of the field 1 of the closure
(the environment?) which raises this exception.

Can someone confirm that such a behaviour is possible whenever the
environment contains a value tagged as abstract? Or in any other cases?

If that is a known behaviour for Marshal.to_string, maybe it could be
properly documented?

Best regards,
Julien Signoles

</contents>

</message>

