[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Basile Starynkevitch <basile.starynkevitch@i...> |
| Subject: | Re: [Caml-list] line numbers in exceptions |
On Wed, Oct 08, 2003 at 02:04:33PM -0400, Lex Stein wrote: > Hi, Is there a general strategy for getting the line number information > into exceptions. [...] Is there something like cpp's > __LINE__ and __FILE__ macros in OCaml? For macros, use camlp4. Exceptions don't carry more luggage than what they claim, so if you want your exception SomeFault to carry the line & file information, you obviously need to explicit exception SomeFault of string * int (* filename linenumber *) Then you want to have a macro which e.g. expands a single (your new) keyword raise_Fault into raise SomeFault(__FILE__,__LINE__) where of course __FILE__ is a string (you want your preprocessor to put the filename here) and __LINE__ is a number (you want your preprocessor to put the current line number here). As an example of macros which magically expands into something containing the current source filename and line (& column) number, you can look at the trace macro in the file pa_trace.ml (see also README.trace) inside http://cvs.sourceforge.net/viewcvs.py/poesia/PoesiaSoft/PoesiaMonIcap/ I hope this will help you. Feel free to ask for more details if so needed. -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - phone +33 1 3963 5197 - mobile 6 8501 2359 http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners