all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using let-bound var inside pcase conditions
@ 2017-04-17 18:07 Kaushal Modi
  2017-04-17 20:33 ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Kaushal Modi @ 2017-04-17 18:07 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi,

I am trying to set the conditions in a pcase to variables, but cannot get
it working (See below dummy code).

Can you help fix the second message form below?

;; -*- lexical-binding: t; -*-

(defun pcase-test (var)
  (let ((one 1)
        (two 2))

    (message "(good) Value is %s." (pcase var
                                     (`nil "nil")
                                     (1 "one")
                                     (2 "two")
                                     (_ "none of the expected")))
    (message "(bad)  Value is %s." (pcase var
                                     (`nil "nil")
                                     (`,one "one")
                                     (`,two "two")
                                     (_ "none of the expected")))))
(pcase-test nil)
(pcase-test 1)
(pcase-test 2)
(pcase-test 3)

-- 

Kaushal Modi


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

end of thread, other threads:[~2017-04-17 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-17 18:07 Using let-bound var inside pcase conditions Kaushal Modi
2017-04-17 20:33 ` Michael Heerdegen
2017-04-17 20:40   ` Kaushal Modi

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.