emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 39b2a59: Make pcase pattern 'eieio' respect slot access related f


From: Stefan Monnier
Subject: master 39b2a59: Make pcase pattern 'eieio' respect slot access related functions.
Date: Fri, 8 May 2020 11:08:08 -0400 (EDT)

branch: master
commit 39b2a598d27809c524a123fd53db71783693071e
Author: Zhu Zihao <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Make pcase pattern 'eieio' respect slot access related functions.
    
    * lisp/emacs-lisp/eieio.el: Make pcase pattern respect slot-missing and
    slot-unbound
---
 lisp/emacs-lisp/eieio.el | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index fe2b80b..999d75f 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -359,16 +359,13 @@ contents of field NAME is matched against PAT, or they 
can be of
     ;; FIXME: `pcase' does not do a good job here of sharing tests&code among
     ;; various branches.
     `(and (pred eieio-object-p)
-          (app eieio-pcase-slot-index-table ,is)
-          ,@(mapcar (lambda (field)
-                      (let* ((name (if (consp field) (car field) field))
-                             (pat (if (consp field) (cadr field) field))
-                             (i (make-symbol "index")))
-                        `(and (let (and ,i (pred natnump))
-                                (eieio-pcase-slot-index-from-index-table
-                                 ,is ',name))
-                              (app (pcase--flip aref ,i) ,pat))))
-                    fields))))
+        ,@(mapcar (lambda (field)
+                    (pcase-exhaustive field
+                      (`(,name ,pat)
+                        `(app (pcase--flip eieio-oref ',name) ,pat))
+                      ((pred symbolp)
+                       `(app (pcase--flip eieio-oref ',field) ,field))))
+                  fields))))
 
 ;;; Simple generators, and query functions.  None of these would do
 ;;  well embedded into an object.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]