Bruno Loff <[EMAIL PROTECTED]> writes:
[...]
> Ideally, I'd like to be able to do
> (my-compile "file1.lisp" "file1.out")
> (my-compile "file2.lisp" "file2.out")
> and get an output of the sort:
> Compiling "file1.lisp"...
> file1.lisp:21:error: "asd" isn't a symbol
> file1.lisp:320:warning: undefined symbol SUPER-SPECIAL
> Failed to compile "file1.lisp": 1 errors (and 1 warnings)
> Compiling "file2.lisp"...
> Successfuly compiled "file2.lisp": 0 warnings.
Yeah, such a format would be useful as the compiler could be used like
a typical batch compiler in combination with low-tech tools like
Emacs' compile commands.
> I'm not aware if the spec refers to the way error messages are suposed
> to be displayed, but I personally find cmucl's error reporting
> discouraging.
I mostly agree. The messages are pretty good; less good is the
indication of the source location. But it is less painful if you use
something like Hemlock or SLIME. Both can show you the source location
for error messages.
> If there is no way of doing this in today's cmucl, I would like to
> improve cmucl's error reporting.
There's no explicit support for this format. But handling compiler
conditions should work (most of the time). E.g.:
(defun my-compile (filename)
(handler-bind ((c::compiler-error #'handle-compiler-condition)
(c::style-warning #'handle-compiler-condition)
(c::warning #'handle-compiler-condition))
(compile-file filename :print nil)))
(defun handle-compiler-condition (c)
(format c::*compiler-error-output* "~A: ~A~%" (c::find-error-context nil) c)
(let ((restart (or (find-restart 'muffle-warning c)
(find-restart 'continue c))))
(invoke-restart restart)))
In handler-compiler-condition you can do your own bookkeeping.
find-error-context can be used to get the source location. But it
doesn't provide the line number, only the "source path". With some
effort, it's possible to get the line number for the path. Look at
the SLIME or Hemlock source for details.
The debugger is usually not invoked for simple errors like:
(format *standard-output* "Error: ~A" error)
The compiler prints only an error message (assuming ERROR is a free
variable). The debugger pops up later, when you load or execute the
code. If the source of the error is not obvious you can use the "view
source" command in the debugger. Also Hemlock and SLIME have
something similar.
Helmut.