aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2018-05-20 20:32:48 +0200
committerThien-Thi Nguyen2018-05-20 20:32:48 +0200
commit53973de6a9bbb99bde9216d1e39fcc5981850cc8 (patch)
treed5f6756a08d44152d149166a76161a7781d1cdca
parent455f990ceb387cd4393f143d26d91d123fe7a90b (diff)
downloademacs-53973de6a9bbb99bde9216d1e39fcc5981850cc8.tar.gz
emacs-53973de6a9bbb99bde9216d1e39fcc5981850cc8.zip
refine QPAT table
- do ‘s/backquoted pattern/backquote-style pattern/g’ - use singular in intro blurb - do ‘s/qpattern/qpat/g’ - do ‘s/backquoted lists/lists/’ (DWR: "backquote" overload!) - use "literal object" - mention @var{pattern} as unrestricted kind - add inline example (‘second-elem’ as SYMBOL) - add post-table para to define "corresponding element" - add inline example (again ‘second-elem’)
-rw-r--r--doc/lispref/control.texi34
1 files changed, 22 insertions, 12 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index fe01531e7f5..febbe19aabc 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -933,36 +933,46 @@ and avoids binding @code{ls}:
933`("first" ,second-elem) 933`("first" ,second-elem)
934@end example 934@end example
935 935
936Backquoted patterns have the form @code{`@var{qpattern}} where 936A backquote-style pattern has the form @code{`@var{qpat}} where
937@var{qpattern} can have the following forms: 937@var{qpat} can have the following forms:
938 938
939@table @code 939@table @code
940 940
941@item (@var{qpattern1} . @var{qpattern2}) 941@item (@var{qpat1} . @var{qpat2})
942Matches if @var{expval} is a cons cell whose @code{car} 942Matches if @var{expval} is a cons cell whose @code{car}
943matches @var{qpattern1} and whose @code{cdr} matches @var{qpattern2}. 943matches @var{qpat1} and whose @code{cdr} matches @var{qpat2}.
944This readily generalizes to backquoted lists as in 944This readily generalizes to lists as in
945@w{@code{(@var{qpattern1} @var{qpattern2} @dots{})}}. 945@w{@code{(@var{qpat1} @var{qpat2} @dots{})}}.
946 946
947@item [@var{qpattern1} @var{qpattern2} @dots{} @var{qpatternm}] 947@item [@var{qpat1} @var{qpat2} @dots{} @var{qpatm}]
948Matches if @var{expval} is a vector of length @var{m} whose 948Matches if @var{expval} is a vector of length @var{m} whose
949@code{0}..@code{(@var{m}-1)}th elements match @var{qpattern1}, 949@code{0}..@code{(@var{m}-1)}th elements match @var{qpat1},
950@var{qpattern2} @dots{} @var{qpatternm}, respectively. 950@var{qpat2} @dots{} @var{qpatm}, respectively.
951 951
952@item @var{symbol} 952@item @var{symbol}
953@itemx @var{keyword} 953@itemx @var{keyword}
954@itemx @var{integer} 954@itemx @var{integer}
955@itemx @var{string} 955@itemx @var{string}
956Matches if the corresponding element of @var{expval} is 956Matches if the corresponding element of @var{expval} is
957@code{equal} to the specified object. 957@code{equal} to the specified literal object.
958Note that, aside from @var{symbol}, this is the same set of 958Note that, aside from @var{symbol}, this is the same set of
959self-quoting types that are acceptable as a core pattern. 959self-quoting literal objects that are acceptable as a core pattern.
960 960
961@item ,@var{pattern} 961@item ,@var{pattern}
962Matches if the corresponding element of @var{expval} 962Matches if the corresponding element of @var{expval}
963matches the @var{pattern}. 963matches @var{pattern}.
964Note that @var{pattern} is any kind that @code{pcase} supports.
965(In the example above, @code{second-elem} is a @var{symbol}
966core pattern; it therefore matches anything,
967and let-binds @code{second-elem}.)
964@end table 968@end table
965 969
970The @dfn{corresponding element} is the portion of @var{expval}
971that is in the same structural position as the structural position
972of @var{qpat} in the backquote-style pattern.
973(In the example above, the corresponding element of
974@code{second-elem} is the second element of @var{expval}.)
975
966Note that uses of Q-patterns can be expressed using only core 976Note that uses of Q-patterns can be expressed using only core
967patterns, as Q-patterns are implemented on top of core patterns using 977patterns, as Q-patterns are implemented on top of core patterns using
968@code{pcase-defmacro}, described below. However, using Q-patterns will 978@code{pcase-defmacro}, described below. However, using Q-patterns will