1
0
Fork 0
cl-sites/novaspec.org/cl/f_signal.html
2025-02-05 18:52:26 +01:00

313 lines
No EOL
6.8 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>signal | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_signal.html"
><LINK REL="next" HREF="t_simple-condition.html" TYPE="text/html" TITLE="simple-condition"
><LINK REL="prev" HREF="f_method-combination-error.html" TYPE="text/html" TITLE="method-combination-error"
><LINK REL="up" HREF="9_2_Conditions_Dictionary.html" TYPE="text/html" TITLE="9.2 Conditions Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="9_Conditions.html"
>9. Conditions</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="9_2_Conditions_Dictionary.html"
>9.2 Conditions Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_signal.html"
>signal</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_method-combination-error.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="t_simple-condition.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="signal"
></SPAN
><B
>signal</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Function</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>signal</B
> <SPAN CLASS="cmssi"
>datum</SPAN
> <SPAN CLASS="cmtt"
>&amp;rest</SPAN
> <SPAN CLASS="cmssi"
>arguments</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="misc"
><B
>nil</B
></SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>datum</VAR
>, <VAR CLASS="param"
>arguments</VAR
> &#8212; <A HREF="26_1_Glossary.html#designator"
><EM CLASS="term"
>designators</EM
></A
> for a <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>condition</EM
></A
> of default type <A HREF="t_simple-condition.html" CLASS="typeref"
><B
>simple-condition</B
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
><A HREF="26_1_Glossary.html#signal"
><EM CLASS="term"
>Signals</EM
></A
> the <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>condition</EM
></A
> denoted by the given <VAR CLASS="param"
>datum</VAR
> and <VAR CLASS="param"
>arguments</VAR
>. If the <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>condition</EM
></A
> is not handled, <A HREF="f_signal.html" CLASS="funref"
><B
>signal</B
></A
> returns <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
> (defun handle-division-conditions (condition)
(format t "Considering condition for division condition handling~%")
(when (and (typep condition 'arithmetic-error)
(eq '/ (arithmetic-error-operation condition)))
(invoke-debugger condition)))
HANDLE-DIVISION-CONDITIONS
(defun handle-other-arithmetic-errors (condition)
(format t "Considering condition for arithmetic condition handling~%")
(when (typep condition 'arithmetic-error)
(abort)))
HANDLE-OTHER-ARITHMETIC-ERRORS
(define-condition a-condition-with-no-handler (condition) ())
A-CONDITION-WITH-NO-HANDLER
(signal 'a-condition-with-no-handler)
NIL
(handler-bind ((condition #'handle-division-conditions)
(condition #'handle-other-arithmetic-errors))
(signal 'a-condition-with-no-handler))
Considering condition for division condition handling
Considering condition for arithmetic condition handling
NIL
(handler-bind ((arithmetic-error #'handle-division-conditions)
(arithmetic-error #'handle-other-arithmetic-errors))
(signal 'arithmetic-error :operation '* :operands '(1.2 b)))
Considering condition for division condition handling
Considering condition for arithmetic condition handling
Back to Lisp Toplevel</PRE
></DD
><DT
><B
>Side Effects</B
></DT
><DD
><P CLASS="j"
>The debugger might be entered due to <A HREF="v_break-on-signals.html" CLASS="varref"
><B
>*break-on-signals*</B
></A
>. </P
><P CLASS="j"
>Handlers for the condition being signaled might transfer control.</P
></DD
><DT
><B
>Affected By</B
></DT
><DD
><P CLASS="j"
>Existing handler bindings. </P
><P CLASS="j"
><A HREF="v_break-on-signals.html" CLASS="varref"
><B
>*break-on-signals*</B
></A
></P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="v_break-on-signals.html" CLASS="varref"
><B
>*break-on-signals*</B
></A
>, <A HREF="f_error.html" CLASS="funref"
><B
>error</B
></A
>, <A HREF="t_simple-condition.html" CLASS="typeref"
><B
>simple-condition</B
></A
>, <A HREF="9_1_Condition_System_Concepts.html#sec_9_1_4" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>9.1.4</SPAN
> <SPAN CLASS="cmr"
>(Signaling</SPAN
> <SPAN CLASS="cmr"
>and</SPAN
> <SPAN CLASS="cmr"
>Handling</SPAN
> <SPAN CLASS="cmr"
>Conditions)</SPAN
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
>If <CODE CLASS="f"
>(typep <VAR CLASS="param"
>datum</VAR
> *break-on-signals*)</CODE
> <A HREF="26_1_Glossary.html#yield"
><EM CLASS="term"
>yields</EM
></A
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, the debugger is entered prior to beginning the signaling process. The <SPAN CLASS="misc"
><B
>continue</B
></SPAN
> <A HREF="26_1_Glossary.html#restart"
><EM CLASS="term"
>restart</EM
></A
> can be used to continue with the signaling process. This is also true for all other <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>functions</EM
></A
> and <A HREF="26_1_Glossary.html#macro"
><EM CLASS="term"
>macros</EM
></A
> that should, might, or must <A HREF="26_1_Glossary.html#signal"
><EM CLASS="term"
>signal</EM
></A
> <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>conditions</EM
></A
>.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_method-combination-error.html" CLASS="prev"
>&#8592;</A
><A HREF="t_simple-condition.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>