[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Checking conditions unrelated to expression
From: |
Stefan Monnier |
Subject: |
Re: Checking conditions unrelated to expression |
Date: |
Sun, 08 Dec 2024 11:01:47 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> Suppose I want to test (eq duck 'quack), cannot use a pcase because tests
> are dependent upon featr.
>
> (pcase featr
> ('this (do-this))
> ('that (do-that))
> (_ (message "some message"))
Like Thibaut said, for this example `cond` would probably work best.
But if you have good reasons to use `pcase`, you *can* do what
you suggest.
E.g.:
(pcase featr
('this (do-this))
('that (do-that))
(_ (if (eq duck 'quack) (do-not) (message "some message"))))
or
(pcase featr
('this (do-this))
('that (do-that))
((guard (eq duck 'quack)) (do-not))
(_ (message "some message")))
or
(pcase featr
('this (do-this))
('that (do-that))
((let 'quack duck) (do-not))
(_ (message "some message")))
...
Stefan