Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Troubles with C->Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: malc <malc@p...>
Subject: [Caml-list] Troubles with C->Caml

====
value f (value u) 
{
  value result;
  value res = <some function>;
  if (Is_exception_result (res)) {
#ifdef FULL
    result = alloc_small (1, 2);
    Field (result, 0) = <some value>;
    Field (result, 1) = Extract_exception (res);
#else
    result = alloc_small (1, 1);
    Field (result, 0) = Extract_exception (res);
#endif
    return result;
  }

  result = alloc_small (0, 1);
  Field (result, 0) = <some value>;
  return result;
}
===
type t
type result = A of t | B of (t * exn)

external cfunc : unit -> result = "f"

let _ =
  match cfunc () with
    A t -> print_endline "ok"
  | B (t, e) -> prerr_endline (Printexc.to_string e)
===

The above dumps core in Printexc.to_string, what am i doing wrong here?
Why if: "type result = A of t | B of exn" and -DFULL everything works
fine?

-- 
mailto:malc@pulsesoft.com

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr