mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
; Fix some issues in core documentation for cond*.
This commit is contained in:
parent
7586a5474c
commit
51b883719b
2 changed files with 40 additions and 34 deletions
|
|
@ -1493,25 +1493,27 @@ argument:
|
|||
@subsection The @code{cond*} macro
|
||||
@findex cond*@r{, a macro}
|
||||
|
||||
The @code{cond*} macro is an alternative to @code{pcase}, and supports
|
||||
the same functionality, but using syntax that some might find less
|
||||
cryptic.
|
||||
You can use the @code{cond*} macro as an alternative to @code{pcase}
|
||||
if you find @code{pcase}'s syntax too cryptic. In addition,
|
||||
@code{cond*} offers some new forms of control flow that aren't related
|
||||
to being an alternative to @code{pcase}.
|
||||
|
||||
@defmac cond* &rest clauses
|
||||
The @code{cond*} macro is an extended form of the traditional
|
||||
@code{cond}. A @code{cond*} expression contains a series of
|
||||
@var{clauses}, each of which can use @code{bind*} to specify binding
|
||||
variables, use @code{match*} to specify matching a pattern as a
|
||||
condition, or specify an expression as a condition to evaluate as a
|
||||
test.
|
||||
@var{clauses}, each of which can use @code{bind*} or @code{bind-and*} to
|
||||
specify binding variables, use @code{match*} or @code{pcase*} to specify
|
||||
matching a pattern as a condition, or specify an expression as a
|
||||
condition to evaluate as a test.
|
||||
|
||||
Each clause normally has the form @w{@code{(@var{condition}
|
||||
@var{body}@dots{})}}.
|
||||
|
||||
@var{condition} can be a Lisp expression, as in @code{cond}
|
||||
(@pxref{Conditionals}). Or it can be @w{@code{(bind*
|
||||
@var{bindings}@dots{})}} or @w{@code{(match* @var{pattern}
|
||||
@var{datum})}}.
|
||||
@var{bindings}@dots{})}}, @w{@code{(match* @var{pattern} @var{datum})}},
|
||||
@w{@code{(bind-and* @var{bindings}@dots{})}} or @w{@code{(pcase*
|
||||
@var{pattern} @var{datum})}}
|
||||
|
||||
@findex bind*
|
||||
@code{(bind* @var{bindings}@dots{})} means to bind @var{bindings} (like
|
||||
|
|
@ -1522,10 +1524,10 @@ true if the first binding's value is non-@code{nil}.
|
|||
@findex bind-and*
|
||||
@code{(bind-and* @var{bindings}@dots{})} means to bind @var{bindings}
|
||||
(like the bindings list in @code{if-let*}, @pxref{Conditionals}) for
|
||||
only the body of the clause. As a condition, it counts as true if none
|
||||
of the bindings evaluate to @code{nil}. In addition, if any binding
|
||||
evaluates to @code{nil}, the expressions for the values of subsequent
|
||||
bindings are not evaluated.
|
||||
only the body of the clause. It is always a non-exit clause. As a
|
||||
condition, it counts as true if none of the bindings evaluate to
|
||||
@code{nil}. In addition, if any binding evaluates to @code{nil}, the
|
||||
expressions for the values of subsequent bindings are not evaluated.
|
||||
|
||||
@findex match*
|
||||
@findex pcase*
|
||||
|
|
@ -1536,23 +1538,24 @@ bind to the parts of @var{datum} that they match.
|
|||
@code{(pcase* @var{pattern} @var{datum})} works in the same way except it
|
||||
uses the Pcase syntax for @var{pattern}.
|
||||
|
||||
@code{bind*}, @code{match*}, and @code{pcase*} normally bind their bindings over
|
||||
the execution of the whole containing clause. However, if the clause is
|
||||
written to specify ``non-exit'', the clause's bindings cover the whole
|
||||
rest of the @code{cond*}.
|
||||
@code{match*}, and @code{pcase*} normally bind their bindings over the
|
||||
execution of the whole containing clause. However, if the clause is
|
||||
written to specify ``non-exit'' (see below), the clause's bindings cover
|
||||
the whole rest of the @code{cond*}.
|
||||
|
||||
When a clause's condition is true, and it exits the @code{cond*} or is
|
||||
the last clause, the value of the last expression in the clause's body
|
||||
becomes the return value of the @code{cond*} construct.
|
||||
|
||||
@subheading Non-exit clause
|
||||
@subheading Non-exit clauses
|
||||
|
||||
If a clause has only one element, or if its first element is @code{t},
|
||||
or if it ends with the keyword @code{:non-exit}, then this clause never
|
||||
exits the @code{cond*} construct. Instead, control falls through to the
|
||||
next clause (if any). The bindings made in @var{condition} for the
|
||||
@var{body} of the non-exit clause are passed along to the rest of the
|
||||
clauses in this @code{cond*} construct.
|
||||
If a clause has only one element, or if its first element is @code{t}, a
|
||||
@code{bind*} or a @code{bind-and*} clause, or if it ends with the
|
||||
keyword @code{:non-exit}, then this clause never exits the @code{cond*}
|
||||
construct. Instead, control falls through to the next clause (if any).
|
||||
Except for @code{bind-and*}, the bindings made in @var{condition} for
|
||||
the @var{body} of the non-exit clause are passed along to the rest of
|
||||
the clauses in this @code{cond*} construct.
|
||||
|
||||
Note: @code{pcase*} does not support @code{:non-exit}, and when used in
|
||||
a non-exit clause, it follows the semantics of @code{pcase-let}, see
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ normally has the form (CONDITION BODY...).
|
|||
|
||||
CONDITION can be a Lisp expression, as in `cond'.
|
||||
Or it can be one of `(bind* BINDINGS...)', `(match* PATTERN DATUM)',
|
||||
or `(pcase* PATTERN DATUM)',
|
||||
`(bind-and* BINDINGS...)' or `(pcase* PATTERN DATUM)',
|
||||
|
||||
`(bind* BINDINGS...)' means to bind BINDINGS (as if they were in `let*')
|
||||
for the body of the clause, and all subsequent clauses, since the `bind*'
|
||||
|
|
@ -70,8 +70,9 @@ For its patterns, see `match*'.
|
|||
The condition counts as true if PATTERN matches DATUM.
|
||||
|
||||
`(bind-and* BINDINGS...)' means to bind BINDINGS (as if they were in
|
||||
`if-let*') for only the the body of the clause. If any expression
|
||||
evaluates to nil, the condition counts as false.
|
||||
`if-let*') for only the the body of the clause. It is always a non-exit
|
||||
clause. If any expression evaluates to nil, the condition counts as
|
||||
false.
|
||||
|
||||
`(pcase* PATTERN DATUM)' means to match DATUM against the
|
||||
pattern PATTERN, using the same pattern syntax as `pcase'.
|
||||
|
|
@ -81,15 +82,17 @@ When a clause's condition is true, and it exits the `cond*'
|
|||
or is the last clause, the value of the last expression
|
||||
in its body becomes the return value of the `cond*' construct.
|
||||
|
||||
Non-exit clause:
|
||||
Non-exit clauses:
|
||||
|
||||
If a clause has only one element, or if its first element is
|
||||
t or a `bind*' clause, this clause never exits the `cond*' construct.
|
||||
Instead, control always falls through to the next clause (if any).
|
||||
All bindings made in CONDITION for the BODY of the non-exit clause
|
||||
are passed along to the rest of the clauses in this `cond*' construct.
|
||||
If a clause has only one element, or if its first element is t, a
|
||||
`bind*' clause or a `bind-and*' clause, then this clause never exits the
|
||||
`cond*' construct. Instead, control always falls through to the next
|
||||
clause (if any). Except for `bind-and*', all bindings made in CONDITION
|
||||
for the BODY of the non-exit clause are passed along to the rest of the
|
||||
clauses in this `cond*' construct.
|
||||
|
||||
\\[match*] for documentation of the patterns for use in `match*'."
|
||||
See `match*' for documentation of the patterns for use in `match*'
|
||||
conditions."
|
||||
;; FIXME: Want an Edebug declaration.
|
||||
(cond*-convert clauses))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue