emacs-devel
[Top][All Lists]
Advanced

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

Re: Replace trivial pcase occurrences in the Emacs sources


From: Stefan Monnier
Subject: Re: Replace trivial pcase occurrences in the Emacs sources
Date: Tue, 30 Oct 2018 09:07:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> In fact, when you think about it, the "case" nature of pcase is pretty
> orthogonal to the "match/destructure" nature of pcase. If anything

How do you suggest to split the two in cases like:

    (defun cconv-convert (form env extend)
      (pcase form
        (`(,(and letsym (or `let* `let)) ,binders . ,body)
         ...)
    
        (`(,(and `(lambda . ,_) fun) . ,args)
         ...)
        
        (`(cond . ,cond-forms)
         ...)
    
        (`(function (lambda ,args . ,body) . ,_)
         ...)
    
        (`(internal-make-closure . ,_)
         ...)
    
        (`(quote . ,_) form)
        (`(function . ,_) form)
    
        (`(,(and sym (or `defconst `defvar)) ,definedsymbol . ,forms)
         ...)
    
        ((and `(condition-case ,var ,protected-form . ,handlers)
              (guard byte-compile--use-old-handlers))
         ...)
    
        (`(condition-case ,var ,protected-form . ,handlers)
         ...)
    
        (`(,(and head (or (and `catch (guard byte-compile--use-old-handlers))
                          `unwind-protect))
           ,form . ,body)
         ...)
    
        (`(setq . ,forms)
         ...)
    
        (`(,(and (or `funcall `apply) callsym) ,fun . ,args)
         ...)
    
        (`(interactive . ,forms)
         ...)

        (`(declare . ,_) form)

        (`(,func . ,forms)
         ...)

        (_
         ...)))

That kind of use is the main motivation behind the design of pcase.

Once you have this, you also trivially cover the `cl-case` uses and you
can easily make it handle the "destructuring" uses.
Splitting the two will just require more code to get less flexibility.


        Stefan




reply via email to

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