caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Marshal.to_string and closures
@ 2009-01-22 14:38 Julien SIGNOLES
  0 siblings, 0 replies; only message in thread
From: Julien SIGNOLES @ 2009-01-22 14:38 UTC (permalink / raw)
  To: caml-list

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 _ -> 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 _ -> 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-22 14:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-22 14:38 Marshal.to_string and closures Julien SIGNOLES

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