[Top][All Lists]

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

Re: Common Lisp like feature expressions

From: Leo
Subject: Re: Common Lisp like feature expressions
Date: Tue, 28 Dec 2010 15:26:31 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.91 (Mac OS X 10.6.5)

On 2010-12-28 01:01 +0000, Stefan Monnier wrote:
> Just for fun, here's a version using pcase:
>  (defun eval-feature-expression (form)
>    (pcase form
>     ((pred atom) (featurep form nil))
>     (`(not ,x) (not (eval-feature-expression x)))
>     (`(and) t)
>     (`(and ,form1 . ,forms)
>      (and (eval-feature-expression form1)
>           (eval-feature-expression (cons 'and forms))))
>     (`(or) nil)
>     (`(or ,form1 . ,forms)
>      (or (eval-feature-expression form1)
>          (eval-feature-expression (cons 'or forms))))
>     (t (error "Invalid feature expression: %s" form)))))

That appears to be an excellent example for pcase. Maybe it should be
added to the header of pcase.el or where it is documented? Thanks.


reply via email to

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