[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reporting errors at macro-expansion time



    Date: Fri, 8 Jul 88 23:34 EDT
    From: miller@acorn.cs.rochester.edu (Brad Miller)

    Is there a good (read: appropriate) way to report errors to the user that
    are detected at macro expansion time?

    I'm thinking of something along the following lines:

    (defmacro foo (x)
      (typecase x
	(keyword
	  `(mumble ,x))
	(symbol
	  `(mumble (eval ,x)))
	(t
	  (ERROR))))

    That is, the macro will detect an erronious argument (or some other problem)
    at expansion time, and thus should do something appropriate, other than drop
    into the debugger, maybe? I'm hoping there's something along the lines of
    sys:read-error which I can't use here since I don't know the stream.

What I do is use warn instead of error, and have the macro expand to something
safe, like nil.  The warning gets collected into the compiler warnings
database, and can be taken care of by the programmer with all the other
compiler warnings.