From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: pcase and minus-sign Date: Wed, 30 Nov 2016 14:56:18 +0100 Message-ID: <87poldax6l.fsf@fastmail.fm> References: <87r35tb0se.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 1480514220 18626 195.159.176.226 (30 Nov 2016 13:57:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2016 13:57:00 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.1.50.3 Cc: Help Gnu Emacs mailing list To: Andreas =?utf-8?Q?R=C3=B6hler?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 30 14:56:52 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 1cC5NR-00039Q-5f for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 14:56:49 +0100 Original-Received: from localhost ([::1]:44288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC5NV-00086R-3W for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Nov 2016 08:56:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC5N4-00086M-64 for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:56:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC5N1-0007BD-2Z for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:56:26 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:46954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cC5N0-0007Aq-QS for help-gnu-emacs@gnu.org; Wed, 30 Nov 2016 08:56:22 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9F27D2080E; Wed, 30 Nov 2016 08:56:21 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Wed, 30 Nov 2016 08:56:21 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=G9mmZyZJsv1RIOX kvhLlLCJ3UfY=; b=kf6UPmnhnQ7AnbyGAFsm6xI4sdEis126xPdcIANMNEJ6unw IjGmDR0UG/Q2yCdif+UQ4Qfgoj1es7TylHOauDw/60ZeCof7WBprqePJkIq3uoTt AU4tdOcrZjZ5f9MY12lLJKgYhGLHJRYMe4/oTr4k+FpOhikUaokdbmqzgstE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=G9mmZyZJsv1RIOXkvhLlLCJ3UfY=; b=V1fLcWSLJYHN+z4UoRTN O3fawkLcj2B/+U08teVtayrtZMWDRytm/+NVtRlCos+gCC7N6WPQRInPOZXV6XHy 3B1pRUEEWySiY5lBDLAVHKvpDqCk51RdZvLnOuijtJqLTCBMC0uBTI1+h9Kbziq+ R+t21FUAsNcbUg7ouK1ePa8= X-ME-Sender: X-Sasl-enc: TJC+UoAw39cMqhZsyu+s+2yDTK06dRPdTs//681o4ozu 1480514181 Original-Received: from IdeaPad.messagingengine.com (x4d0aed8b.dyn.telefonica.de [77.10.237.139]) by mail.messagingengine.com (Postfix) with ESMTPA id E470A24161; Wed, 30 Nov 2016 08:56:20 -0500 (EST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 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:111834 Archived-At: 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" _)) -- Joost Kremers Life has its moments