On Thursday 04 Nov 2004 11:02 am, David Matthews wrote:
Rob Arthan wrote:
I have a recollection that there is a way of stopping Poly/ML printing out the exception value when an excepation is raised but not caught, but I can't find anything in the structure PolyML that looks likely to do this. Am I mistaken or am I overlooking something?
You were probably thinking of PolyML.error_depth. The primary purpose of this is to control how deep to print the context when reporting compiler error messages but it's also used to control how deep to print the arguments of exceptions. In this case, though, I would have thought that you could have arranged to raise an exception such as Fail instead of, presumably, reraising the original exception.
Thanks, that would have worked if the problem was as I'd described. Having checked, I see I was describing what was more like what I have to do under SML/NJ (which doesn't print out the operands of exception constructors). With Poly/ML what I'm doing is much simpler, the following illustrates my problem (where I'm using conversion to upper case in place of the bit of string processing that I need to do).
fun shout s = ( TextIO.output(TextIO.stdOut, String.map Char.toUpper s); TextIO.flushOut TextIO.stdOut );
fun delay s () = s;
fun run_string s = PolyML.compiler(delay s, shout) ();
exception Fruit of (string * string);
run_string "(raise Fruit ("apple", "banana")) : unit;";
If you run the above, the output from the last line has the exception printed out twice, with my function shout only being involved the first time:
EXCEPTION- FRUIT ("APPLE", "BANANA") RAISED Exception- Fruit ("apple", "banana") raised
What is going on?
Regards,
Rob.