emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 1341185: * lisp/emacs-lisp/pcase.el: Undo last chan


From: Stefan Monnier
Subject: [Emacs-diffs] master 1341185: * lisp/emacs-lisp/pcase.el: Undo last change's spurious changes
Date: Mon, 30 May 2016 20:33:53 +0000 (UTC)

branch: master
commit 13411853b25f3c861d9364961f8ca0b18a9b5ed4
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/emacs-lisp/pcase.el: Undo last change's spurious changes
---
 lisp/emacs-lisp/pcase.el |   50 ++++------------------------------------------
 1 file changed, 4 insertions(+), 46 deletions(-)

diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index b18472d..0b8dddf 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -105,8 +105,6 @@
                 specs)))))
     (edebug-match cursor (cons '&or specs))))
 
-(fset 'pcase--canon #'identity)
-
 ;;;###autoload
 (defmacro pcase (exp &rest cases)
   "Evaluate EXP and attempt to match it against structural patterns.
@@ -334,8 +332,7 @@ any kind of error."
                   ;; to a separate function if that number is too high.
                   ;;
                   ;; We've already used this branch.  So it is shared.
-                  (let* (;; (code (car prev))
-                         (cdrprev (cdr prev))
+                  (let* ((code (car prev))         (cdrprev (cdr prev))
                          (prevvars (car cdrprev))  (cddrprev (cdr cdrprev))
                          (res (car cddrprev)))
                     (unless (symbolp res)
@@ -437,10 +434,8 @@ to this macro."
   ;; Don't use let*, otherwise macroexp-let* may merge it with some surrounding
   ;; let* which might prevent the setcar/setcdr in pcase--expand's fancy
   ;; codegen from later metamorphosing this let into a funcall.
-  (if vars
-      `(let ,(mapcar (lambda (b) (list (car b) (cdr b))) vars)
-         ,@code)
-    `(progn ,@code)))
+  `(let ,(mapcar (lambda (b) (list (car b) (cdr b))) vars)
+     ,@code))
 
 (defun pcase--small-branch-p (code)
   (and (= 1 (length code))
@@ -456,36 +451,7 @@ to this macro."
   (cond
    ((eq else :pcase--dontcare) then)
    ((eq then :pcase--dontcare) (debug) else) ;Can/should this ever happen?
-   ;; FIXME: The code below shows that there are some opportunities for 
sharing,
-   ;; but it's rarely useful to do it here, since almost all sharing found
-   ;; shares a trivial expression.
-   ;; But among the common trivial expressions are those of the form
-   ;; (funcall pcase-0).  For this case, there could be a significant payoff
-   ;; if we could find the sharing-opportunity earlier so as to avoid
-   ;; the creation of pcase-0.
-   ;; ((and (eq 'if (car-safe then))
-   ;;       (equal (macroexp-unprogn (macroexp-progn (nthcdr 3 then)))
-   ;;              (macroexp-unprogn else)))
-   ;;  (let ((res (macroexp-if `(and ,test ,(nth 1 then))
-   ;;                        (nth 2 then) else)))
-   ;;    (message "if+if => if-and: sharing %S" else)
-   ;;    res))
-   ;; ((and (eq 'if (car-safe else))
-   ;;       (equal (nth 2 else) then))
-   ;;  (let ((res (macroexp-if `(or ,test ,(nth 1 else))
-   ;;                          then (macroexp-progn (nthcdr 3 else)))))
-   ;;    (message "if+if => if-or: sharing %S" then)
-   ;;    res))
-   (t
-    ;; (cond
-    ;;  ((and (eq 'cond (car-safe then))
-    ;;        (equal `(cond ,@(nthcdr 2 then)) else))
-    ;;   (message "if+cond => cond-and: sharing %S" else))
-    ;;  ((and (eq 'cond (car-safe else))
-    ;;        (equal (macroexp-unprogn (macroexp-progn (cdr (nth 1 else))))
-    ;;               (macroexp-unprogn then)))
-    ;;   (message "if+cond => cond-or: sharing %S" then)))
-    (macroexp-if test then else))))
+   (t (macroexp-if test then else))))
 
 ;; Note about MATCH:
 ;; When we have patterns like `(PAT1 . PAT2), after performing the `consp'
@@ -953,14 +919,6 @@ QPAT can take the following forms:
    ((or (stringp qpat) (integerp qpat) (symbolp qpat)) `',qpat)
    (t (error "Unknown QPAT: %S" qpat))))
 
-;;; Extra definitions that use pcase.
-
-(defun pcase--canon (e)
-  (pcase e
-    (`(progn ,e) (pcase--canon e))
-    (`(cond (,test . ,then) (t . ,else))
-     `(if ,test ,(macroexp-progn then) ,(macroexp-progn else)))))
-
 
 (provide 'pcase)
 ;;; pcase.el ends here



reply via email to

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