Allow floats as 'pcase' QPATS
* lisp/emacs-lisp/pcase.el (\`): Extend semantics of QPATS to all numbers. Add a comment explaining why we disallow some atoms as QPATS. * doc/lispref/control.texi (Backquote Patterns): Update the paragraph explaining QPATS. Remove a sentence suggesting an analogy between QPATS to self-quoting objects.
This commit is contained in:
parent
fa9679ca48
commit
45ee24efed
2 changed files with 6 additions and 5 deletions
|
@ -1090,12 +1090,10 @@ Matches if @var{expval} is a vector of length @var{m} whose
|
|||
|
||||
@item @var{symbol}
|
||||
@itemx @var{keyword}
|
||||
@itemx @var{integer}
|
||||
@itemx @var{number}
|
||||
@itemx @var{string}
|
||||
Matches if the corresponding element of @var{expval} is
|
||||
@code{equal} to the specified literal object.
|
||||
Note that, aside from @var{symbol}, this is the same set of
|
||||
self-quoting literal objects that are acceptable as a core pattern.
|
||||
|
||||
@item ,@var{pattern}
|
||||
Matches if the corresponding element of @var{expval}
|
||||
|
|
|
@ -919,7 +919,7 @@ QPAT can take the following forms:
|
|||
,PAT matches if the `pcase' pattern PAT matches.
|
||||
SYMBOL matches if EXPVAL is `equal' to SYMBOL.
|
||||
KEYWORD likewise for KEYWORD.
|
||||
INTEGER likewise for INTEGER.
|
||||
NUMBER likewise for NUMBER.
|
||||
STRING likewise for STRING.
|
||||
|
||||
The list or vector QPAT is a template. The predicate formed
|
||||
|
@ -949,7 +949,10 @@ The predicate is the logical-AND of:
|
|||
`(and (pred consp)
|
||||
(app car ,(list '\` (car qpat)))
|
||||
(app cdr ,(list '\` (cdr qpat)))))
|
||||
((or (stringp qpat) (integerp qpat) (symbolp qpat)) `',qpat)
|
||||
((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat)
|
||||
;; In all other cases just raise an error so we can't break
|
||||
;; backward compatibility when adding \` support for other
|
||||
;; compounded values that are not `consp'
|
||||
(t (error "Unknown QPAT: %S" qpat))))
|
||||
|
||||
(provide 'pcase)
|
||||
|
|
Loading…
Add table
Reference in a new issue