all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: phillip.lord@russet.org.uk (Phillip Lord)
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Quick pcase question
Date: Wed, 02 Mar 2016 12:40:28 +0000	[thread overview]
Message-ID: <87mvqh9hoj.fsf@russet.org.uk> (raw)
In-Reply-To: <87lh615gt8.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Wed, 2 Mar 2016 18:12:51 +0800")

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> 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)

They are being improved! It might be worth looking at the docs in
the Emacs-25 pre-releases.


> 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.


I think that's it I am afraid. Don't trust me though, I am no expert.

Phil



      parent reply	other threads:[~2016-03-02 12:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvqh9hoj.fsf@russet.org.uk \
    --to=phillip.lord@russet.org.uk \
    --cc=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.