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

615 lines
No EOL
13 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>restart-bind | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_restart-bind.html"
><LINK REL="next" HREF="f_restart-case.html" TYPE="text/html" TITLE="restart-case"
><LINK REL="prev" HREF="f_invoke-restart-interactively.html" TYPE="text/html" TITLE="invoke-restart-interactively"
><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_restart-bind.html"
>restart-bind</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_invoke-restart-interactively.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="f_restart-case.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="restart-bind"
></SPAN
><B
>restart-bind</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Macro</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><DIV CLASS="DefmacWithValuesNewline"
><DIV
><B
>restart-bind</B
> <SPAN CLASS="cmr"
>(</SPAN
><SPAN CLASS="cmsy"
>{</SPAN
><SPAN CLASS="cmr"
>(</SPAN
><SPAN CLASS="cmssi"
>name</SPAN
> <SPAN CLASS="cmssi"
>function</SPAN
> <SPAN CLASS="cmsy"
>{&#8595;</SPAN
><VAR CLASS="param"
>key-val-pair</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*)</SPAN
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>)</SPAN
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>form</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
> </DIV
><DIV
><SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>result</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
></DIV
></DIV
><TABLE CELLSPACING="0" CELLPADDING="0" RULES="GROUPS" STYLE="margin: 1ex 0"
><TBODY
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;padding-right:3px"
><VAR CLASS="param"
>key-val-pair</VAR
><SPAN CLASS="cmssi"
>::</SPAN
><SPAN CLASS="cmr"
>=</SPAN
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:interactive-function</SPAN
></SPAN
> <SPAN CLASS="cmssi"
>interactive-function</SPAN
> <SPAN CLASS="cmsy"
>|</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;padding-right:3px"
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:report-function</SPAN
></SPAN
> <SPAN CLASS="cmssi"
>report-function</SPAN
> <SPAN CLASS="cmsy"
>|</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;padding-right:3px"
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:test-function</SPAN
></SPAN
> <SPAN CLASS="cmssi"
>test-function</SPAN
></TD
></TR
></TBODY
></TABLE
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>name</VAR
> &#8212; a <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
>; not evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>function</VAR
> &#8212; a <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>form</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>forms</VAR
> &#8212; an <A HREF="26_1_Glossary.html#implicit_progn"
><EM CLASS="term"
>implicit progn</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>interactive-function</VAR
> &#8212; a <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>form</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>report-function</VAR
> &#8212; a <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>form</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>test-function</VAR
> &#8212; a <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>form</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>results</VAR
> &#8212; the <A HREF="26_1_Glossary.html#value"
><EM CLASS="term"
>values</EM
></A
> returned by the <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>forms</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
><A HREF="f_restart-bind.html" CLASS="macref"
><B
>restart-bind</B
></A
> executes the body of <VAR CLASS="param"
>forms</VAR
> in a <A HREF="26_1_Glossary.html#dynamic_environment"
><EM CLASS="term"
>dynamic environment</EM
></A
> where <A HREF="26_1_Glossary.html#restart"
><EM CLASS="term"
>restarts</EM
></A
> with the given <VAR CLASS="param"
>names</VAR
> are in effect. </P
><P CLASS="j"
>If a <VAR CLASS="param"
>name</VAR
> is <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>, it indicates an anonymous restart; if a <VAR CLASS="param"
>name</VAR
> is a <A HREF="26_1_Glossary.html#non-nil"
><EM CLASS="term"
>non-nil</EM
></A
> <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
>, it indicates a named restart. </P
><P CLASS="j"
>The <VAR CLASS="param"
>function</VAR
>, <VAR CLASS="param"
>interactive-function</VAR
>, and <VAR CLASS="param"
>report-function</VAR
> are unconditionally evaluated in the current lexical and dynamic environment prior to evaluation of the body. Each of these <A HREF="26_1_Glossary.html#form"
><EM CLASS="term"
>forms</EM
></A
> must evaluate to a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
>. </P
><P CLASS="j"
>If <A HREF="f_invoke-restart.html" CLASS="funref"
><B
>invoke-restart</B
></A
> is done on that restart, the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> which resulted from evaluating <VAR CLASS="param"
>function</VAR
> is called, in the <A HREF="26_1_Glossary.html#dynamic_environment"
><EM CLASS="term"
>dynamic environment</EM
></A
> of the <A HREF="f_invoke-restart.html" CLASS="funref"
><B
>invoke-restart</B
></A
>, with the <A HREF="26_1_Glossary.html#argument"
><EM CLASS="term"
>arguments</EM
></A
> given to <A HREF="f_invoke-restart.html" CLASS="funref"
><B
>invoke-restart</B
></A
>. The <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> may either perform a non-local transfer of control or may return normally. </P
><P CLASS="j"
>If the restart is invoked interactively from the debugger (using <A HREF="f_invoke-restart-interactively.html" CLASS="funref"
><B
>invoke-restart-interactively</B
></A
>), the arguments are defaulted by calling the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> which resulted from evaluating <VAR CLASS="param"
>interactive-function</VAR
>. That <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> may optionally prompt interactively on <A HREF="26_1_Glossary.html#query_I_dashO"
><EM CLASS="term"
>query I/O</EM
></A
>, and should return a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
> of arguments to be used by <A HREF="f_invoke-restart-interactively.html" CLASS="funref"
><B
>invoke-restart-interactively</B
></A
> when invoking the restart. </P
><P CLASS="j"
>If a restart is invoked interactively but no <VAR CLASS="param"
>interactive-function</VAR
> is used, then an argument list of <SPAN CLASS="misc"
><B
>nil</B
></SPAN
> is used. In that case, the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> must be compatible with an empty argument list. </P
><P CLASS="j"
>If the restart is presented interactively (<I CLASS="i"
><I
>e.g.</I
></I
>, by the debugger), the presentation is done by calling the <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> which resulted from evaluating <VAR CLASS="param"
>report-function</VAR
>. This <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> must be a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> of one argument, a <A HREF="26_1_Glossary.html#stream"
><EM CLASS="term"
>stream</EM
></A
>. It is expected to print a description of the action that the restart takes to that <A HREF="26_1_Glossary.html#stream"
><EM CLASS="term"
>stream</EM
></A
>. This <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> is called any time the restart is printed while <A HREF="v_print-escape.html" CLASS="varref"
><B
>*print-escape*</B
></A
> is <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>. </P
><P CLASS="j"
>In the case of interactive invocation, the result is dependent on the value of <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:interactive-function</SPAN
></SPAN
> as follows.</P
><DL
><DT
><SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:interactive-function</SPAN
></SPAN
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>Value</VAR
> is evaluated in the current lexical environment and should return a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> of no arguments which constructs a <A HREF="26_1_Glossary.html#list"
><EM CLASS="term"
>list</EM
></A
> of arguments to be used by <A HREF="f_invoke-restart-interactively.html" CLASS="funref"
><B
>invoke-restart-interactively</B
></A
> when invoking this restart. The <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> may prompt interactively using <A HREF="26_1_Glossary.html#query_I_dashO"
><EM CLASS="term"
>query I/O</EM
></A
> if necessary.</P
></DD
><DT
><SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:report-function</SPAN
></SPAN
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>Value</VAR
> is evaluated in the current lexical environment and should return a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> of one argument, a <A HREF="26_1_Glossary.html#stream"
><EM CLASS="term"
>stream</EM
></A
>, which prints on the <A HREF="26_1_Glossary.html#stream"
><EM CLASS="term"
>stream</EM
></A
> a summary of the action that this restart takes. This <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> is called whenever the restart is reported (printed while <A HREF="v_print-escape.html" CLASS="varref"
><B
>*print-escape*</B
></A
> is <SPAN CLASS="misc"
><B
>nil</B
></SPAN
>). If no <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:report-function</SPAN
></SPAN
> option is provided, the manner in which the <A HREF="26_1_Glossary.html#restart"
><EM CLASS="term"
>restart</EM
></A
> is reported is <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
>.</P
></DD
><DT
><SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:test-function</SPAN
></SPAN
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>Value</VAR
> is evaluated in the current lexical environment and should return a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> of one argument, a <A HREF="26_1_Glossary.html#condition"
><EM CLASS="term"
>condition</EM
></A
>, which returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if the restart is to be considered visible.</P
></DD
></DL
></DD
><DT
><B
>Affected By</B
></DT
><DD
><P CLASS="j"
><A HREF="v_debug-io.html" CLASS="varref"
><B
>*query-io*</B
></A
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_restart-case.html" CLASS="macref"
><B
>restart-case</B
></A
>, <A HREF="f_with-simple-restart.html" CLASS="macref"
><B
>with-simple-restart</B
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
><A HREF="f_restart-bind.html" CLASS="macref"
><B
>restart-bind</B
></A
> is primarily intended to be used to implement <A HREF="f_restart-case.html" CLASS="macref"
><B
>restart-case</B
></A
> and might be useful in implementing other macros. Programmers who are uncertain about whether to use <A HREF="f_restart-case.html" CLASS="macref"
><B
>restart-case</B
></A
> or <A HREF="f_restart-bind.html" CLASS="macref"
><B
>restart-bind</B
></A
> should prefer <A HREF="f_restart-case.html" CLASS="macref"
><B
>restart-case</B
></A
> for the cases where it is powerful enough, using <A HREF="f_restart-bind.html" CLASS="macref"
><B
>restart-bind</B
></A
> only in cases where its full generality is really needed.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_invoke-restart-interactively.html" CLASS="prev"
>&#8592;</A
><A HREF="f_restart-case.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
>