On 29 Mar 2013, at 08:42, Gergely Buday <[email protected]> wrote:
>
> Back to the original question: this is why I would like to suppress any
> compiler message.
>
>
The function PolyML.compiler lets you write your own customised read-eval-print
loop. In the code below, the fun my_read_eval_print_loop is a variant of the
usual one that sends all compiler output to standard error and exits when
standard input runs out. if you put it in my-revl.ML and run
poly < my-revl.ML 1>a 2>b
there will be a small predictable set of compiler messages at the head of file
a followed by the standard output of the other code in my-revl.ML and all the
rest of the compiler messages go in file b. If you make an executable that
runs my_read_eval_print_loop following Phil Clayton's post, then you will get a
program that compiles and runs ML code and sends all compiler messages to
standard error (so you can discard them using 2>/dev/null on the command line).
Regards,
Rob.
=== beginning of my-revl.ML ====
fun read_or_exit () = (
case TextIO.input1 TextIO.stdIn of
NONE => Posix.Process.exit 0wx0
| some => some
);
fun my_read_eval_print_loop () = (
PolyML.compiler (read_or_exit,
[PolyML.Compiler.CPOutStream
(fn s => TextIO.output(TextIO.stdErr, s))]) ();
my_read_eval_print_loop ()
);
val _ = my_read_eval_print_loop();
(* could also do PolyML.export("my-revl", read_eval_print_loop) at this point *)
fun repeat f n = if n <= 0 then () else (f (); repeat f (n-1));
fun say s () = TextIO.output(TextIO.stdOut, s ^ "\n");
val hello = repeat (say "Hello World!");
hello 10;
val goodbye = repeat (say "Goodbye cruel World!");
goodbye 10;
=== end of my-revl.ML ====
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml