warn
warn datum &rest arguments → nil
datum, arguments—designators for a condition of default type simple-warning.
Signals a condition of type warning. If the condition is not handled, reports the condition to error output.
The precise mechanism for warning is as follows:
Discussion of *BREAK-ON-WARNINGS* removed.
!!! Barret wonders whether stylistically it wouldn't be better to have just normal text instead of this indented stuff.
While the warning condition is being signaled, the muffle-warning restart is established for use by a handler. If invoked, this restart bypasses further action by warn, which in turn causes warn to immediately return nil.
If no handlers for the warning condition are found, or if all such handlers decline, then the condition is reported to error output by warn in an implementation-dependent format. Barrett points out that the details of this are already said elsewhere in
the concept info for conditions.
(with possible implementation-specific extra
output such as motion to a fresh line before and/or after the display
of the warning, or supplying some introductory text that might mention
the name of the function which called \funref{warn}
and/or the fact that this is a warning).
nil is returned
(defun foo (x)
(let ((result (* x 2)))
(if (not (typep result 'fixnum))
(warn "You're using very big numbers."))
result))
→ FOO
(foo 3)
→ 6
(foo most-positive-fixnum)
⊳ Warning: You're using very big numbers.
→ 4294967294
(setq *break-on-signals* t)
→ T
(foo most-positive-fixnum)
⊳ Break: Caveat emptor.
⊳ To continue, type :CONTINUE followed by an option number.
⊳ 1: Return from Break.
⊳ 2: Abort to Lisp Toplevel.
⊳ Debug> :continue 1
⊳ Warning: You're using very big numbers.
→ 4294967294
A warning is issued. The debugger might be entered.
Existing handler bindings.
*break-on-signals*, *error-output*.
If datum is a condition and if the condition is not of type warning, or arguments is non-nil, an error of type type-error is signaled.
If datum is a condition type, the result of (apply #'make-condition datum arguments) must be of type warning or an error of type type-error is signaled.
*break-on-signals*, muffle-warning, signal
None.