all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Quick pcase question
@ 2016-03-02 10:12 Eric Abrahamsen
  2016-03-02 11:02 ` Michael Heerdegen
  2016-03-02 12:40 ` Phillip Lord
  0 siblings, 2 replies; 13+ messages in thread
From: Eric Abrahamsen @ 2016-03-02 10:12 UTC (permalink / raw)
  To: help-gnu-emacs

I'm enjoying pcase quite a bit, particular when employed as a kind of
improved destructuring-bind. I think I've got the hang of most of it
(despite the docs being a bit... succinct), but have one leftover
question I keep running into.

What I want to do is: "if this atom matches a predicate, the whole
pattern matches, and also bind the atom to this local variable."

Right now I'm making that work like this:

(setq tst '(symbolla . "I'm the string"))

(pcase tst
  (`(symbolla . ,(and x (pred stringp)))
   (message "cdr is a string: %s" x)))

Is the ",(and x (pred stringp))" part really the simplest way of doing
that? It just seems a little unintuitive.

Thanks,
Eric




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-03-03 12:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-02 10:12 Quick pcase question Eric Abrahamsen
2016-03-02 11:02 ` Michael Heerdegen
2016-03-02 11:18   ` Eric Abrahamsen
2016-03-02 11:38     ` Michael Heerdegen
2016-03-02 11:56       ` Eric Abrahamsen
2016-03-02 12:27         ` Michael Heerdegen
2016-03-02 17:25           ` Phillip Lord
2016-03-03  1:13             ` Eric Abrahamsen
2016-03-03  3:47             ` Stefan Monnier
2016-03-02 17:18     ` Phillip Lord
2016-03-03  1:08       ` Eric Abrahamsen
2016-03-03 12:08         ` Phillip Lord
2016-03-02 12:40 ` Phillip Lord

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.