caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Stricter version of #use ?
@ 2009-03-24 18:00 Harrison, John R
  2009-03-24 22:25 ` Zheng Li
  0 siblings, 1 reply; 4+ messages in thread
From: Harrison, John R @ 2009-03-24 18:00 UTC (permalink / raw)
  To: OCaml

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 "root.ml" containing

  let x = 1;;

  #use "branch.ml";;

  let y = 2;;

and a file "branch.ml" containing

  let u = 3;;

  let v = failwith "X";;

  let w = 4;;

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

          Objective Caml version 3.10.0

  # #use "root.ml";;
  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.)

John.


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

end of thread, other threads:[~2009-03-25  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-24 18:00 Stricter version of #use ? Harrison, John R
2009-03-24 22:25 ` Zheng Li
2009-03-25  0:14   ` Harrison, John R
2009-03-25  8:32     ` Zheng Li

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