Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Stricter version of #use ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Harrison, John R <john.r.harrison@i...>
Subject: Stricter version of #use ?
I'd like a variant of the #use directive for reading in an OCaml
source file, but with the property that it halts immediately on the
first error anywhere in a nesting of #use'd files. For example,
suppose you have a file "" containing

  let x = 1;;

  #use "";;

  let y = 2;;

and a file "" containing

  let u = 3;;

  let v = failwith "X";;

  let w = 4;;

Then I want the following to stop immediately on the failure inside
"" and hence not evaluate the "y = 2" line in "" as it
currently does:

          Objective Caml version 3.10.0

  # #use "";;
  val x : int = 1
  val u : int = 3
  Exception: Failure "X".
  val y : int = 2

On the other hand, I'd want it to keep the results of the x = 1 and
u = 3 lines, not roll back everything. Is this easy to accomplish?
(By the way, I'm ultimately interested in using this together with
camlp5, and possibly with the new camlp4, if that makes a difference.)