aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/control.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref/control.texi')
-rw-r--r--doc/lispref/control.texi43
1 files changed, 24 insertions, 19 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index a4776030cf2..85e13952cfb 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1493,25 +1493,27 @@ argument:
1493@subsection The @code{cond*} macro 1493@subsection The @code{cond*} macro
1494@findex cond*@r{, a macro} 1494@findex cond*@r{, a macro}
1495 1495
1496 The @code{cond*} macro is an alternative to @code{pcase}, and supports 1496 You can use the @code{cond*} macro as an alternative to @code{pcase}
1497the same functionality, but using syntax that some might find less 1497if you find @code{pcase}'s syntax too cryptic. In addition,
1498cryptic. 1498@code{cond*} offers some new forms of control flow that aren't related
1499to being an alternative to @code{pcase}.
1499 1500
1500@defmac cond* &rest clauses 1501@defmac cond* &rest clauses
1501The @code{cond*} macro is an extended form of the traditional 1502The @code{cond*} macro is an extended form of the traditional
1502@code{cond}. A @code{cond*} expression contains a series of 1503@code{cond}. A @code{cond*} expression contains a series of
1503@var{clauses}, each of which can use @code{bind*} to specify binding 1504@var{clauses}, each of which can use @code{bind*} or @code{bind-and*} to
1504variables, use @code{match*} to specify matching a pattern as a 1505specify binding variables, use @code{match*} or @code{pcase*} to specify
1505condition, or specify an expression as a condition to evaluate as a 1506matching a pattern as a condition, or specify an expression as a
1506test. 1507condition to evaluate as a test.
1507 1508
1508Each clause normally has the form @w{@code{(@var{condition} 1509Each clause normally has the form @w{@code{(@var{condition}
1509@var{body}@dots{})}}. 1510@var{body}@dots{})}}.
1510 1511
1511@var{condition} can be a Lisp expression, as in @code{cond} 1512@var{condition} can be a Lisp expression, as in @code{cond}
1512(@pxref{Conditionals}). Or it can be @w{@code{(bind* 1513(@pxref{Conditionals}). Or it can be @w{@code{(bind*
1513@var{bindings}@dots{})}} or @w{@code{(match* @var{pattern} 1514@var{bindings}@dots{})}}, @w{@code{(match* @var{pattern} @var{datum})}},
1514@var{datum})}}. 1515@w{@code{(bind-and* @var{bindings}@dots{})}} or @w{@code{(pcase*
1516@var{pattern} @var{datum})}}
1515 1517
1516@findex bind* 1518@findex bind*
1517@code{(bind* @var{bindings}@dots{})} means to bind @var{bindings} (like 1519@code{(bind* @var{bindings}@dots{})} means to bind @var{bindings} (like
@@ -1536,21 +1538,22 @@ bind to the parts of @var{datum} that they match.
1536@code{(pcase* @var{pattern} @var{datum})} works in the same way except it 1538@code{(pcase* @var{pattern} @var{datum})} works in the same way except it
1537uses the Pcase syntax for @var{pattern}. 1539uses the Pcase syntax for @var{pattern}.
1538 1540
1539@code{bind*}, @code{match*}, and @code{pcase*} normally bind their bindings over 1541@code{match*}, and @code{pcase*} normally bind their bindings over the
1540the execution of the whole containing clause. However, if the clause is 1542execution of the whole containing clause. However, if the clause is
1541written to specify ``non-exit'', the clause's bindings cover the whole 1543written to specify ``non-exit'' (see below), the clause's bindings cover
1542rest of the @code{cond*}. 1544the whole rest of the @code{cond*}.
1543 1545
1544When a clause's condition is true, and it exits the @code{cond*} or is 1546When a clause's condition is true, and it exits the @code{cond*} or is
1545the last clause, the value of the last expression in the clause's body 1547the last clause, the value of the last expression in the clause's body
1546becomes the return value of the @code{cond*} construct. 1548becomes the return value of the @code{cond*} construct.
1547 1549
1548@subheading Non-exit clause 1550@subheading Non-exit clauses
1549 1551
1550If a clause has only one element, or if its first element is @code{t}, 1552If a clause has only one element, or if its first element is @code{t} or
1551or if it ends with the keyword @code{:non-exit}, then this clause never 1553a @code{bind*} form, or if it ends with the keyword @code{:non-exit},
1552exits the @code{cond*} construct. Instead, control falls through to the 1554then this clause never exits the @code{cond*} construct. Instead,
1553next clause (if any). The bindings made in @var{condition} for the 1555control falls through to the next clause (if any). Except for a
1556@code{bind-and*} clause, the bindings made in @var{condition} for the
1554@var{body} of the non-exit clause are passed along to the rest of the 1557@var{body} of the non-exit clause are passed along to the rest of the
1555clauses in this @code{cond*} construct. 1558clauses in this @code{cond*} construct.
1556 1559
@@ -2344,7 +2347,9 @@ the other usual filtering mechanisms say it should. @xref{Error Debugging}.
2344The macro @code{condition-case-unless-debug} provides another way to 2347The macro @code{condition-case-unless-debug} provides another way to
2345handle debugging of such forms. It behaves exactly like 2348handle debugging of such forms. It behaves exactly like
2346@code{condition-case}, unless the variable @code{debug-on-error} is 2349@code{condition-case}, unless the variable @code{debug-on-error} is
2347non-@code{nil}, in which case it does not handle any errors at all. 2350non-@code{nil}, in which case it causes Emacs to enter the debugger
2351before executing any applicable handler. (The applicable handler, if
2352any, will still run when the debugger exits.)
2348@end defmac 2353@end defmac
2349 2354
2350 Once Emacs decides that a certain handler handles the error, it 2355 Once Emacs decides that a certain handler handles the error, it