From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Andreas_R=c3=b6hler?= Newsgroups: gmane.emacs.help Subject: Re: pcase and minus-sign Date: Wed, 30 Nov 2016 16:23:57 +0100 Message-ID: References: <87r35tb0se.fsf@fastmail.fm> <87poldax6l.fsf@fastmail.fm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1480518975 6226 195.159.176.226 (30 Nov 2016 15:16:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2016 15:16:15 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Icedove/45.4.0 Cc: Michael Heerdegen , Help Gnu Emacs mailing list To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 30 16:16:11 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 1cC6cD-0000zm-Ho for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 16:16:09 +0100 Original-Received: from localhost ([::1]:44613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC6cH-0004Oj-D2 for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 10:16:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC6bS-0004LG-P3 for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 10:15:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC6bO-00011U-CV for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 10:15:22 -0500 Original-Received: from mout.kundenserver.de ([212.227.126.133]:49543) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cC6bO-00011A-2Z for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 10:15:18 -0500 Original-Received: from [192.168.178.35] ([77.12.119.56]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MTKL8-1cJ9Js27UM-00SBVT; Wed, 30 Nov 2016 16:15:08 +0100 In-Reply-To: <87poldax6l.fsf@fastmail.fm> X-Provags-ID: V03:K0:YnonN9A1ZeyM3su8y9fV3xx6riejvA7UcJTNi/H0hyr90xZiJdv Q2UgJEEJcY7nWbB3XTw0ObN6PvAvgxaoJPDJAmTVIwVAx3S9Ps3PxRnPDxvuM5hhHzgrSmZ ge5i3RMfc6nbh9udiB14sjvAKKa9u/AkmFsJ6NdzwxYo/wqUM5s2C5ybl6GHkqH6ko/EUxt gql8aXbZLckN1001WM2AQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:fi5C1Fg3Vjk=:jFMWKhr0YB/iwzUsGR/gDQ naJedRO+RHPFMXA9T5M+hTLtp3XAjALo6JG8P0++EfWy44xJFb/sjBAQ6ueDaov4/u3QHlyVn jLr6W1pun68tUuj7/FjIvizs1cgIGrpgEbkamvz2jSwndWTb5TmidBz7qZQaveZ54b5/1vVCL e938APNPDQJZS5oMlPx7FpKnbDPAdfE3vTQPcwOsKC08tG0IDveIPM0wocF9alehsRzEzkqRE MfwWuSR6YZvPlbKOPvRCS5mBVypjF0EpsyV5NcdlBKmuBvaupAq1AYY3Z76H1O/LM9RJLff/z ZvHqCAX5HuB3vZgVRddlGKmjVYYqKeESBbCNIWCFDlnQeNb2HYGUypvQOccaU4lItXAn3uiuU Pp9nCUuFTEISI3EisVjou3yz4gF8JUMxRjDhz/amhYgIUUi/HTHK9+ilzIaaNdUQ9ixpVYPld IBbc/EKzh5GS09Q4YhCjcmFwv8dQTGPtHRJjAm6ivJMZf3+48VTgZanzmby7TQ21Nv+YqBkct bOmjcPls0Kdq14LG1+klbvlMZLQ3mEGWAYJKNJh752A6yIK0ptS0TgakvJ844tLcoeb5MNZe0 oBizb8V/Dm5/YUrohMnQE/OBtF2O9li528s88uxB7o/alVbyld8c2LWM6oVlCbJCpRobmypcB gOVIOUtsKCkJeaSDE9KYV9AvnUvQi3dWu8/wDG1IkDyBlaeMdd3jg3EhnZeI7EjmmXWn5WU9r 2ZYalG6jz0J/qcmj X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 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:111835 Archived-At: On 30.11.2016 14:56, Joost Kremers wrote: > > On Wed, Nov 30 2016, Andreas Röhler wrote: >> Thanks, that helps. Seems it relates to the following in docstring: >> >> SYMBOL matches anything and binds it to SYMBOL. > > Yup. > >> Now if I use some arbitrary char, like "a", >> >> (defun foo (arg) >> (interactive "P") >> (pcase arg >> (a (message "%s" "ARG was `a'")) >> (1 (message "%s" "ARG was `1'")) >> ('- (message "%s" "ARG was minus-sign")) >> (_ (message "%s" "ARG not minus-sign")))) >> >> It picks that a-branch at any case - as documented but strange. > > I don't think it's strange, TBH. `a' is essentially a let-bound > variable. Having the ability to bind values is extremely useful in > pcase, I'd say. > > It may be a bit surprising that - functions the same way, but it's not > strange once you realise that - is not a special character in Lisp > (unlike most other programming languages). For example, the following > code works fine: > > (let ((- "hi")) > (message "%s" -)) > > Note BTW that the same if true for the underscore: in your example, _ > is also just a symbol used to let-bind some value. The only special > thing about _ is that the byte-compiler doesn't complain about an > unused variable if its name starts with an underscore. But again, the > following code works just fine: > > (let ((_ "hi")) > (message "%s" _)) > > > Hmm, thanks all. 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"))))