emacs-devel
[Top][All Lists]
Advanced

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

Re: A protest against pcase, pcase-let, pcase-let*


From: Stefan Monnier
Subject: Re: A protest against pcase, pcase-let, pcase-let*
Date: Wed, 01 Apr 2015 09:53:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> There are much better, more lisp idiomatic, libs for doing pattern
> matching which pcase should give way to imo.

> Shadchen for example.

I don't see much difference.  AFAICT if there's a particular pattern of
shadchen you like, you/we can add it to pcase with `pcase-defmacro' and
IIUC both sets of patterns are perfectly compatible (and very similar
in spirit).
You can also add any of pcase's patterns to shadchen via its
defpattern construct, AFAICT).

It differs in implementation technique, tho, since AFAICT in shadchen

   (match X
     ((cons 1 a) (foo1))
     ((cons 2 a) (foo2)))

will tests `listp' twice and will extract the car of X twice (i.e. it
does not optimize the second branch based on the knowledge of how the
first branch's pattern failed to match).

I guess the main difference you'll see is that shadchen supports
backquote via `bq' and `uq' rather than via ` and , so

   (pcase X
     (`(1 . ,a) (foo1))
     (`(2 . ,a) (foo2)))

turns into

   (match X
    ((bq (1 (uq a))) (foo1))
    ((bq (2 (uq a))) (foo2)))

which is so hideous that noone will ever use it.  IIUC you don't like
the backquote syntax in patterns, so shadchen making it even more
hideous than it already is suits you better.


        Stefan



reply via email to

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