From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: pcase and minus-sign Date: Thu, 01 Dec 2016 21:30:48 -0500 Message-ID: References: <87r35tb0se.fsf@fastmail.fm> <87poldax6l.fsf@fastmail.fm> <87oa0xas0j.fsf@fastmail.fm> <1a633aa5-75e4-f18f-ef97-7adb10589e79@easy-emacs.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1480688786 21993 195.159.176.226 (2 Dec 2016 14:26:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2016 14:26:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 02 15:26:21 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCon6-0004RE-ID for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 15:26:20 +0100 Original-Received: from localhost ([::1]:34789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCon8-0007j1-UT for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 09:26:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCdcr-0002rQ-0S for help-gnu-emacs@gnu.org; Thu, 01 Dec 2016 21:31:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCdcn-0007sC-UH for help-gnu-emacs@gnu.org; Thu, 01 Dec 2016 21:31:01 -0500 Original-Received: from [195.159.176.226] (port=47857 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCdcn-0007rb-Nl for help-gnu-emacs@gnu.org; Thu, 01 Dec 2016 21:30:57 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cCdcg-0005Fb-HT for help-gnu-emacs@gnu.org; Fri, 02 Dec 2016 03:30:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:ukWXE0ZjYrq3VP+u1/bpM90A7hQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Fri, 02 Dec 2016 09:25:37 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111853 Archived-At: >>> But what make the char `a' so special WRT char `1'?: >>> >>> (defun foo (arg) >>> (interactive "P") >>> (pcase arg >>> (1 (message "%s" "ARG was `1'")) >>> (a (message "%s" "ARG was `a'")) >>> ('- (message "%s" "ARG was minus-sign")) >>> (_ (message "%s" "ARG not minus-sign")))) >> >> The same thing that makes it different in "normal" Lisp code. 1 is read as >> an integer, not as a symbol. > Thanks all again! BTW, the driving idea behind the shape of pcase patterns is more or less that a pattern PAT matches the value V if an expression PAT could evaluate to the value V. So for the pattern 1, it will match any value that is equal to the evaluation of the expression 1, i.e. it only matches the value 1. For pattern 'a, it will match any value that is equal to the evaluation of the expression 'a, which means it the value has to be the symbol `a`. Whereas for pattern a, it will match any value that can be equal to the evaluation of the expression a, which means any value (under the assumption that the variable `a` has the appropriate value). Stefan