diff options
| author | Thien-Thi Nguyen | 2018-05-20 20:32:48 +0200 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2018-05-20 20:32:48 +0200 |
| commit | 53973de6a9bbb99bde9216d1e39fcc5981850cc8 (patch) | |
| tree | d5f6756a08d44152d149166a76161a7781d1cdca | |
| parent | 455f990ceb387cd4393f143d26d91d123fe7a90b (diff) | |
| download | emacs-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.texi | 34 |
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 | ||
| 936 | Backquoted patterns have the form @code{`@var{qpattern}} where | 936 | A 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}) |
| 942 | Matches if @var{expval} is a cons cell whose @code{car} | 942 | Matches if @var{expval} is a cons cell whose @code{car} |
| 943 | matches @var{qpattern1} and whose @code{cdr} matches @var{qpattern2}. | 943 | matches @var{qpat1} and whose @code{cdr} matches @var{qpat2}. |
| 944 | This readily generalizes to backquoted lists as in | 944 | This 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}] |
| 948 | Matches if @var{expval} is a vector of length @var{m} whose | 948 | Matches 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} |
| 956 | Matches if the corresponding element of @var{expval} is | 956 | Matches if the corresponding element of @var{expval} is |
| 957 | @code{equal} to the specified object. | 957 | @code{equal} to the specified literal object. |
| 958 | Note that, aside from @var{symbol}, this is the same set of | 958 | Note that, aside from @var{symbol}, this is the same set of |
| 959 | self-quoting types that are acceptable as a core pattern. | 959 | self-quoting literal objects that are acceptable as a core pattern. |
| 960 | 960 | ||
| 961 | @item ,@var{pattern} | 961 | @item ,@var{pattern} |
| 962 | Matches if the corresponding element of @var{expval} | 962 | Matches if the corresponding element of @var{expval} |
| 963 | matches the @var{pattern}. | 963 | matches @var{pattern}. |
| 964 | Note that @var{pattern} is any kind that @code{pcase} supports. | ||
| 965 | (In the example above, @code{second-elem} is a @var{symbol} | ||
| 966 | core pattern; it therefore matches anything, | ||
| 967 | and let-binds @code{second-elem}.) | ||
| 964 | @end table | 968 | @end table |
| 965 | 969 | ||
| 970 | The @dfn{corresponding element} is the portion of @var{expval} | ||
| 971 | that is in the same structural position as the structural position | ||
| 972 | of @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 | |||
| 966 | Note that uses of Q-patterns can be expressed using only core | 976 | Note that uses of Q-patterns can be expressed using only core |
| 967 | patterns, as Q-patterns are implemented on top of core patterns using | 977 | patterns, 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 |