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

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

Re: pcase and minus-sign


From: Joost Kremers
Subject: Re: pcase and minus-sign
Date: Wed, 30 Nov 2016 13:38:25 +0100
User-agent: mu4e 0.9.17; emacs 25.1.50.3


On Wed, Nov 30 2016, Andreas Röhler wrote:
Hi,

see code below. With numerical argument "1", first pattern is matched as expected.

However without arg the minus is matched - the second pattern, not the default "_" at last.

Any explanation?

(defun foo (arg)
   (interactive "P")
   (pcase arg
     (1 (message "%s" "ARG was `1'"))
     (- (message "%s" "ARG was minus-sign"))
     (_ (message "%s" "ARG not minus-sign"))))

Probably because - is a symbol and hence a variable. It works if you quote it:

(defun foo (arg)
 (interactive "P")
 (pcase arg
   (1 (message "%s" "ARG was `1'"))
   ('- (message "%s" "ARG was minus-sign"))
   (_ (message "%s" "ARG not minus-sign"))))



--
Joost Kremers
Life has its moments



reply via email to

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