[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13126: 24.3.50; (WISH) Document pcase in Info manual
From: |
Stefan Monnier |
Subject: |
bug#13126: 24.3.50; (WISH) Document pcase in Info manual |
Date: |
Tue, 11 Dec 2012 08:55:34 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> Thanks. `pcase' seemed a good replacement for `case'.
While it's not a plug-in replacement, it provides a superset of the
features of case, yes.
> 1. pcase-let, pcase-let*, pcase-dolist (maybe)
pcase-dolist shouldn't be documented (yet?). Maybe pcase-let and
pcase-let* should be there, indeed.
> 2. It took some effort to understand that there is a U-PATTERN and a
> UPATTERN. We don't read out `*-*', do we?
> ,----
> | There are two kinds of patterns involved in `pcase', called
> | _U-patterns_ and _Q-patterns_. The UPATTERN mentioned above are
> | U-patterns and can take the following forms:
> `----
What do you suggest instead?
> 3. Let's take the example of how
> ,----
> | (defun evaluate (exp env)
> | (pcase exp
> | ,----
> | | (`(add ,x ,y) (+ (evaluate x env) (evaluate y env)))
> | `----
> | (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env)))
> | (`(fn ,arg ,body) (lambda (val)
> | (evaluate body (cons (cons arg val) env))))
> | ((pred numberp) exp)
> | ((pred symbolp) (cdr (assq exp env)))
> | (_ (error "Unknown expression %S" exp))))
> `----
> `(add ,x ,y)
> ` QPATTERN
I don't know what you wanted to say here.
Stefan