diff options
Diffstat (limited to 'doc/lispref/control.texi')
| -rw-r--r-- | doc/lispref/control.texi | 43 |
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} |
| 1497 | the same functionality, but using syntax that some might find less | 1497 | if you find @code{pcase}'s syntax too cryptic. In addition, |
| 1498 | cryptic. | 1498 | @code{cond*} offers some new forms of control flow that aren't related |
| 1499 | to being an alternative to @code{pcase}. | ||
| 1499 | 1500 | ||
| 1500 | @defmac cond* &rest clauses | 1501 | @defmac cond* &rest clauses |
| 1501 | The @code{cond*} macro is an extended form of the traditional | 1502 | The @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 |
| 1504 | variables, use @code{match*} to specify matching a pattern as a | 1505 | specify binding variables, use @code{match*} or @code{pcase*} to specify |
| 1505 | condition, or specify an expression as a condition to evaluate as a | 1506 | matching a pattern as a condition, or specify an expression as a |
| 1506 | test. | 1507 | condition to evaluate as a test. |
| 1507 | 1508 | ||
| 1508 | Each clause normally has the form @w{@code{(@var{condition} | 1509 | Each 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 |
| 1537 | uses the Pcase syntax for @var{pattern}. | 1539 | uses 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 |
| 1540 | the execution of the whole containing clause. However, if the clause is | 1542 | execution of the whole containing clause. However, if the clause is |
| 1541 | written to specify ``non-exit'', the clause's bindings cover the whole | 1543 | written to specify ``non-exit'' (see below), the clause's bindings cover |
| 1542 | rest of the @code{cond*}. | 1544 | the whole rest of the @code{cond*}. |
| 1543 | 1545 | ||
| 1544 | When a clause's condition is true, and it exits the @code{cond*} or is | 1546 | When a clause's condition is true, and it exits the @code{cond*} or is |
| 1545 | the last clause, the value of the last expression in the clause's body | 1547 | the last clause, the value of the last expression in the clause's body |
| 1546 | becomes the return value of the @code{cond*} construct. | 1548 | becomes the return value of the @code{cond*} construct. |
| 1547 | 1549 | ||
| 1548 | @subheading Non-exit clause | 1550 | @subheading Non-exit clauses |
| 1549 | 1551 | ||
| 1550 | If a clause has only one element, or if its first element is @code{t}, | 1552 | If a clause has only one element, or if its first element is @code{t} or |
| 1551 | or if it ends with the keyword @code{:non-exit}, then this clause never | 1553 | a @code{bind*} form, or if it ends with the keyword @code{:non-exit}, |
| 1552 | exits the @code{cond*} construct. Instead, control falls through to the | 1554 | then this clause never exits the @code{cond*} construct. Instead, |
| 1553 | next clause (if any). The bindings made in @var{condition} for the | 1555 | control 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 |
| 1555 | clauses in this @code{cond*} construct. | 1558 | clauses in this @code{cond*} construct. |
| 1556 | 1559 | ||
| @@ -2344,7 +2347,9 @@ the other usual filtering mechanisms say it should. @xref{Error Debugging}. | |||
| 2344 | The macro @code{condition-case-unless-debug} provides another way to | 2347 | The macro @code{condition-case-unless-debug} provides another way to |
| 2345 | handle debugging of such forms. It behaves exactly like | 2348 | handle 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 |
| 2347 | non-@code{nil}, in which case it does not handle any errors at all. | 2350 | non-@code{nil}, in which case it causes Emacs to enter the debugger |
| 2351 | before executing any applicable handler. (The applicable handler, if | ||
| 2352 | any, 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 |