help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using let-bound var inside pcase conditions


From: Kaushal Modi
Subject: Using let-bound var inside pcase conditions
Date: Mon, 17 Apr 2017 18:07:42 +0000

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]