From unknown Sun Jun 22 03:56:26 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#13126 <13126@debbugs.gnu.org> To: bug#13126 <13126@debbugs.gnu.org> Subject: Status: 24.3.50; (WISH) Document pcase in Info manual Reply-To: bug#13126 <13126@debbugs.gnu.org> Date: Sun, 22 Jun 2025 10:56:26 +0000 retitle 13126 24.3.50; (WISH) Document pcase in Info manual reassign 13126 emacs submitter 13126 Jambunathan K severity 13126 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 09 04:26:28 2012 Received: (at submit) by debbugs.gnu.org; 9 Dec 2012 09:26:28 +0000 Received: from localhost ([127.0.0.1]:33601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Thd9X-0003Nu-Lx for submit@debbugs.gnu.org; Sun, 09 Dec 2012 04:26:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36889) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Thd9V-0003Nn-Mu for submit@debbugs.gnu.org; Sun, 09 Dec 2012 04:26:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Thd92-0006iy-29 for submit@debbugs.gnu.org; Sun, 09 Dec 2012 04:25:56 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-102.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_XBL,T_DKIM_INVALID,USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:39747) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Thd91-0006iu-VA for submit@debbugs.gnu.org; Sun, 09 Dec 2012 04:25:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Thd90-0007ku-R8 for bug-gnu-emacs@gnu.org; Sun, 09 Dec 2012 04:25:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Thd8z-0006ic-EY for bug-gnu-emacs@gnu.org; Sun, 09 Dec 2012 04:25:54 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:37208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Thd8z-0006iY-5o for bug-gnu-emacs@gnu.org; Sun, 09 Dec 2012 04:25:53 -0500 Received: by mail-pa0-f41.google.com with SMTP id bj3so1343240pad.0 for ; Sun, 09 Dec 2012 01:25:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=49NeStItqR4ei/CHwYGSxAqu/qgb6M9vebBpZn0XTBo=; b=Wr6uCCsIOe8BaManIleKRvjii10UF0HJjkXl0PuqdPJKMYuN/Akl0D2od1IbuXTnNF ZJ+jTqyI/bPwg5XXB7LTV2D2+Ypunn0K9NOYcxtzNITql3ncaRIATiWtRLuk0cCK3HVB t4l9gPRvbDTbVO+ol8Oaz8IIy0yboFiQTG8d7lQSA4HsU59KKme5DkCFpC9VN+xDSu+j haMx1jmvRwfbGLF/i3/rggXfnKqJTBcTuHEoZXRhCDu5AzAMJNkrrYR+W95Jsi12PHCK VspU1qX6OSZld7/Tk0O2/fMEJhUhf5NMbvCVCS9sMnHlzPWltvO+SnX8lfFOaVXn2Ur7 ac2Q== Received: by 10.68.197.197 with SMTP id iw5mr29491890pbc.22.1355045152017; Sun, 09 Dec 2012 01:25:52 -0800 (PST) Received: from debian-6.05 ([101.63.218.21]) by mx.google.com with ESMTPS id s5sm6195180pay.31.2012.12.09.01.25.48 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Dec 2012 01:25:50 -0800 (PST) From: Jambunathan K To: bug-gnu-emacs@gnu.org Subject: 24.3.50; (WISH) Document pcase in Info manual Date: Sun, 09 Dec 2012 14:58:49 +0530 Message-ID: <87fw3fpoa6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 24.3.50; Document pcase in Info manual Having easy to use examples would be nice. ,---- | pcase is an autoloaded Lisp macro in `pcase.el'. | | (pcase EXP &rest CASES) | | Perform ML-style pattern matching on EXP. | CASES is a list of elements of the form (UPATTERN CODE...). `---- In GNU Emacs 24.3.50.12 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2012-12-09 on debian-6.05 Bzr revision: 111153 kjambunathan@gmail.com-20121208130646-kfndebrxbw82i48h Windowing system distributor `The X.Org Foundation', version 11.0.10707000 Important settings: value of $LANG: en_IN locale-coding-system: iso-latin-1-unix default enable-multibyte-characters: t From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 09 12:13:30 2012 Received: (at 13126) by debbugs.gnu.org; 9 Dec 2012 17:13:30 +0000 Received: from localhost ([127.0.0.1]:34303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ThkRW-0006ai-9F for submit@debbugs.gnu.org; Sun, 09 Dec 2012 12:13:30 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:15761) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ThkRT-0006ab-Pv for 13126@debbugs.gnu.org; Sun, 09 Dec 2012 12:13:28 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09soXOY/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCws0EhQYDSSIHAW6CZBEA4hCmnGBWIMH X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="209462956" Received: from 108-161-115-152.dsl.teksavvy.com (HELO pastel.home) ([108.161.115.152]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 09 Dec 2012 12:12:55 -0500 Received: by pastel.home (Postfix, from userid 20848) id 87CF158D3B; Sun, 9 Dec 2012 12:12:55 -0500 (EST) From: Stefan Monnier To: Jambunathan K Subject: Re: bug#13126: 24.3.50; (WISH) Document pcase in Info manual Message-ID: References: <87fw3fpoa6.fsf@gmail.com> Date: Sun, 09 Dec 2012 12:12:55 -0500 In-Reply-To: <87fw3fpoa6.fsf@gmail.com> (Jambunathan K.'s message of "Sun, 09 Dec 2012 14:58:49 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13126 Cc: 13126@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) > 24.3.50; Document pcase in Info manual I just installed a doc for it in the `emacs-24' branch. Please take a look at it, Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 09 15:41:57 2012 Received: (at control) by debbugs.gnu.org; 9 Dec 2012 20:41:57 +0000 Received: from localhost ([127.0.0.1]:34362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ThnhE-0002xo-IY for submit@debbugs.gnu.org; Sun, 09 Dec 2012 15:41:57 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:50715) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ThnhC-0002xh-E6 for control@debbugs.gnu.org; Sun, 09 Dec 2012 15:41:54 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Thngg-0000nC-Ld for control@debbugs.gnu.org; Sun, 09 Dec 2012 15:41:22 -0500 Date: Sun, 09 Dec 2012 15:41:22 -0500 Message-Id: Subject: control message for bug 13126 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) forcemerge 12752 13126 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 11 05:18:21 2012 Received: (at 13126) by debbugs.gnu.org; 11 Dec 2012 10:18:21 +0000 Received: from localhost ([127.0.0.1]:36441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiMur-0001nG-8e for submit@debbugs.gnu.org; Tue, 11 Dec 2012 05:18:21 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:57352) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiMun-0001n7-I5 for 13126@debbugs.gnu.org; Tue, 11 Dec 2012 05:18:19 -0500 Received: by mail-pa0-f44.google.com with SMTP id hz11so2718422pad.3 for <13126@debbugs.gnu.org>; Tue, 11 Dec 2012 02:17:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; bh=t3UZKRUFDlN/iTikhjZ28R3KjFX3krzHuqLV1YiV2cw=; b=N08Ld+0ooBalgxAXEoU+a0xMxKXy2Ol2cveVz1U58sXDi8fjrHbJo5O2I6IJnG3IFy OZMvLqWREty29P6FHBlJCS3ReLduvN91jiUDH+qc5kCbgLv6LCmzAdTRti98ihEE0goP 6M+38ACqhDTEuCDoyLO3B/8wtNpSRZ0N4KsI4zFqxEnJa1gHyNwCpiVYdFfjKTb9QSmd 0C80pZMhM9NoW3YVNPMOBLXsfsaA04K4yZzZxEYH18mhj2rMwUiaJQVFaCbJPd+fpG49 hh2EXifM+ktYK3taODJeVREHVLBq03rG5W37d99OgWJq0Rf6+yag6QFkj/VFmimtpg8m 6r/g== Received: by 10.68.241.232 with SMTP id wl8mr46738188pbc.144.1355221056605; Tue, 11 Dec 2012 02:17:36 -0800 (PST) Received: from debian-6.05 ([101.62.98.148]) by mx.google.com with ESMTPS id l5sm13651406paz.14.2012.12.11.02.17.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Dec 2012 02:17:35 -0800 (PST) From: Jambunathan K To: Stefan Monnier Subject: Re: bug#13126: 24.3.50; (WISH) Document pcase in Info manual References: <87fw3fpoa6.fsf@gmail.com> Date: Tue, 11 Dec 2012 15:50:42 +0530 Message-ID: <87txrslwjp.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 13126 Cc: 13126@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) >> 24.3.50; Document pcase in Info manual > > I just installed a doc for it in the `emacs-24' branch. Please take > a look at it, Thanks. `pcase' seemed a good replacement for `case'. Quick feedback. 1. pcase-let, pcase-let*, pcase-dolist (maybe) 2. It took some effort to understand that there is a U-PATTERN and a UPATTERN. We don't read out `*-*', do we? ,---- | There are two kinds of patterns involved in `pcase', called | _U-patterns_ and _Q-patterns_. The UPATTERN mentioned above are | U-patterns and can take the following forms: `---- 3. Let's take the example of how ,---- | (defun evaluate (exp env) | (pcase exp | ,---- | | (`(add ,x ,y) (+ (evaluate x env) (evaluate y env))) | `---- | (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env))) | (`(fn ,arg ,body) (lambda (val) | (evaluate body (cons (cons arg val) env)))) | ((pred numberp) exp) | ((pred symbolp) (cdr (assq exp env))) | (_ (error "Unknown expression %S" exp)))) `---- `(add ,x ,y) ` QPATTERN From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 11 08:56:23 2012 Received: (at 13126) by debbugs.gnu.org; 11 Dec 2012 13:56:23 +0000 Received: from localhost ([127.0.0.1]:36637 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiQJo-0007k0-8X for submit@debbugs.gnu.org; Tue, 11 Dec 2012 08:56:22 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:34589) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TiQJk-0007jr-Qs for 13126@debbugs.gnu.org; Tue, 11 Dec 2012 08:56:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09soXOY/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCws0EhQYDSSIHAW6CZBEA4hCmnGBWIMH X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="209591091" Received: from 108-161-115-152.dsl.teksavvy.com (HELO pastel.home) ([108.161.115.152]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Dec 2012 08:55:35 -0500 Received: by pastel.home (Postfix, from userid 20848) id A2B52520E1; Tue, 11 Dec 2012 08:55:34 -0500 (EST) From: Stefan Monnier To: Jambunathan K Subject: Re: bug#13126: 24.3.50; (WISH) Document pcase in Info manual Message-ID: References: <87fw3fpoa6.fsf@gmail.com> <87txrslwjp.fsf@gmail.com> Date: Tue, 11 Dec 2012 08:55:34 -0500 In-Reply-To: <87txrslwjp.fsf@gmail.com> (Jambunathan K.'s message of "Tue, 11 Dec 2012 15:50:42 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 13126 Cc: 13126@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) > Thanks. `pcase' seemed a good replacement for `case'. While it's not a plug-in replacement, it provides a superset of the features of case, yes. > 1. pcase-let, pcase-let*, pcase-dolist (maybe) pcase-dolist shouldn't be documented (yet?). Maybe pcase-let and pcase-let* should be there, indeed. > 2. It took some effort to understand that there is a U-PATTERN and a > UPATTERN. We don't read out `*-*', do we? > ,---- > | There are two kinds of patterns involved in `pcase', called > | _U-patterns_ and _Q-patterns_. The UPATTERN mentioned above are > | U-patterns and can take the following forms: > `---- What do you suggest instead? > 3. Let's take the example of how > ,---- > | (defun evaluate (exp env) > | (pcase exp > | ,---- > | | (`(add ,x ,y) (+ (evaluate x env) (evaluate y env))) > | `---- > | (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env))) > | (`(fn ,arg ,body) (lambda (val) > | (evaluate body (cons (cons arg val) env)))) > | ((pred numberp) exp) > | ((pred symbolp) (cdr (assq exp env))) > | (_ (error "Unknown expression %S" exp)))) > `---- > `(add ,x ,y) > ` QPATTERN I don't know what you wanted to say here. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 13 09:59:55 2012 Received: (at 13126) by debbugs.gnu.org; 13 Dec 2012 14:59:55 +0000 Received: from localhost ([127.0.0.1]:41060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjAGQ-0001ZP-TR for submit@debbugs.gnu.org; Thu, 13 Dec 2012 09:59:55 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:34264) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjAGJ-0001Yz-UA for 13126@debbugs.gnu.org; Thu, 13 Dec 2012 09:59:51 -0500 Received: by mail-pa0-f44.google.com with SMTP id hz11so1596174pad.3 for <13126@debbugs.gnu.org>; Thu, 13 Dec 2012 06:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=m1ZGoVZKEBcdJRlNG92GTdTZCdZThHs4aEydFe4+G0E=; b=0bIDTd0edNMi/7dvQqCIPHFUndCcLLZK+5cQzFeW2shcXhC6ZrlfXHXqkEsFS440w+ JiV58GPMqQXnluyeDR9pIRTLxFrg4S28CcSiWSQzWy/gMmQeRNaPgxTC4uR7L5/4sb9x 8uy10pzBzsMGKuUjx+erH3rzg3jscbPYO8JWxQXmWxOqzqF6z/t5iNni+qySCfGahoC3 Avntb5uARMDKgLlItDJEZ+jzDmHJGqbxdQ7PTkHWtXRDuz6Na+3fqdy3Y3gfya8qlhAX NiDo/YKbxFZAVb4RbOlZER6fQhDN46tH61NjcXYFjN15AUBYg4NdXW76zXwRGC4zUHNi eLRA== Received: by 10.66.82.33 with SMTP id f1mr6789098pay.11.1355410732379; Thu, 13 Dec 2012 06:58:52 -0800 (PST) Received: from debian-6.05 ([115.184.39.134]) by mx.google.com with ESMTPS id rk17sm1161120pbb.3.2012.12.13.06.58.48 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 06:58:51 -0800 (PST) From: Jambunathan K To: Stefan Monnier Subject: Re: bug#13126: 24.3.50; (WISH) Document pcase in Info manual References: <87fw3fpoa6.fsf@gmail.com> <87txrslwjp.fsf@gmail.com> Date: Thu, 13 Dec 2012 20:31:57 +0530 In-Reply-To: (Stefan Monnier's message of "Tue, 11 Dec 2012 08:55:34 -0500") Message-ID: <87fw3a2dy2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 13126 Cc: 13126@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Stefan Monnier writes: >> Thanks. `pcase' seemed a good replacement for `case'. > > While it's not a plug-in replacement, it provides a superset of the > features of case, yes. pcase also reminds me of CL's case. Btw, you know in what version of Emacs did pcase made it's appearance. >> 1. pcase-let, pcase-let*, pcase-dolist (maybe) > > pcase-dolist shouldn't be documented (yet?). Maybe pcase-let and > pcase-let* should be there, indeed. > pcase-let reminds me of `destructuring-bind'. Here is a real-life example of pcase-let in action from midnight.el. Good for instructive purposes. (defun midnight-next () "Return the number of seconds till the next midnight." (pcase-let ((`(,sec ,min ,hrs) (decode-time))) (- (* 24 60 60) (* 60 60 hrs) (* 60 min) sec))) >> 2. It took some effort to understand that there is a U-PATTERN and a >> UPATTERN. We don't read out `*-*', do we? >> ,---- >> | There are two kinds of patterns involved in `pcase', called >> | _U-patterns_ and _Q-patterns_. The UPATTERN mentioned above are >> | U-patterns and can take the following forms: >> `---- Provide a BNF and document TERMINALS before NON-TERMINALS. (Currently it seems other way round). Docstring for pcase has more info (pred FUNCTION) apropos the arguments passed to it. Possibly there are other things... > What do you suggest instead? Here is my recommendation. May be replace the example snippets with a /simple/ and /cohesive/ example. I found Snippet 2 "too abstract" and leaves a lot to the imagination of the reader. I just hacked a working REPL based on pcase. See below. We can include these after `repl' will act as a good replacement for Snippet 1. `repl-eval' will act as a good replacement for Snippet 2. M-x repl RET for a reader to toy with. ,---- Snippet 1 | (pcase (get-return-code x) | (`success (message "Done!")) | (`would-block (message "Sorry, can't do it now")) | (`read-only (message "The shmliblick is read-only")) | (`access-denied (message "You do not have the needed rights")) | (code (message "Unknown return code %S" code))) `---- ,---- Snippet 2 | (defun evaluate (exp env) | (pcase exp | (`(add ,x ,y) (+ (evaluate x env) (evaluate y env))) | (`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env))) | (`(fn ,arg ,body) (lambda (val) | (evaluate body (cons (cons arg val) env)))) | ((pred numberp) exp) | ((pred symbolp) (cdr (assq exp env))) | (_ (error "Unknown expression %S" exp)))) `---- (let ((repl-dictionary '())) (repl-eval '((x = "happy") (y = "HACKING") (n = 2013) (z = (upcase-initials x + space + (downcase y) + tab + 2013))))) (defvar repl-dictionary '() "Symbol table for `repl'.") (defun repl-eval (exp) (pcase exp ;; In-built constants. (`space " ") (`tab "\t") ;; Add operator. Concatenate. (`(,x + . ,y) (concat (repl-eval x ) (repl-eval y))) ;; Assignment operator. Update dictionary. (`(,x = . ,body) (let* ((value (repl-eval body)) (entry (assoc x repl-dictionary))) (if (not entry) ;; Add variable & value. (push (cons x value) repl-dictionary) ;; Update value. (setcdr entry value)) value)) ;; Function. Assume it takes a string as it's only arg. Call it. (`(,(and (pred functionp) f) . ,x) (funcall f (repl-eval x))) ;; Last of body forms. Return it's value. (`(,x . nil) (repl-eval x)) ;; Body forms. Evaluate in sequence. Return value of last of ;; the forms. (`(,x . ,y) (repl-eval x) (repl-eval y)) ;; String, just return it. ((pred stringp) exp) ;; Number, cast it to string. ((pred numberp) (number-to-string exp)) ;; Symbol, lookup it's value in dictionary. ((pred symbolp) (or (cdr (assoc exp repl-dictionary)) (error "Variable `%s' not bound" exp))) (_ (error "Unknown expression %S" exp)))) (defun repl () "Simple REPL for string operations. Expression syntax: In-built Constants : space : tab Assignment : x = \"hello\" : y = \"world\" Casting : n = 2012 Concatenation : x + space + y + space + n Unary functions : (upcase-initials x) Commands: exit => Quit clear => Unbind all variables examine => Examine currently defined variables." (interactive) (let ((repl-dictionary '()) (prompt "STRING-REPL> ") (result nil)) (while (pcase (read-from-minibuffer prompt) (input (pcase input ("exit" (setq result nil)) ("clear" (setq repl-dictionary '() result "[CLEARED]")) ("examine" (setq result (format "%S" repl-dictionary))) (_ (let ((exp (read (format "(%s)" input)))) (setq result (condition-case err (repl-eval exp) (error (format "%s" err))))))) (when result (minibuffer-message (concat prompt input (propertize "\t" 'display (list 'space :align-to 40)) (propertize result 'face 'highlight)))))) (setq result nil)))) From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 13 14:43:19 2012 Received: (at 13126) by debbugs.gnu.org; 13 Dec 2012 19:43:19 +0000 Received: from localhost ([127.0.0.1]:41271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjEgg-00020F-Iu for submit@debbugs.gnu.org; Thu, 13 Dec 2012 14:43:19 -0500 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:33150) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TjEgd-000205-Nj for 13126@debbugs.gnu.org; Thu, 13 Dec 2012 14:43:16 -0500 Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.DIT.UMontreal.CA (8.14.1/8.14.1) with ESMTP id qBDJgL3m021766; Thu, 13 Dec 2012 14:42:21 -0500 Received: by pastel.home (Postfix, from userid 20848) id 583BD5942A; Thu, 13 Dec 2012 12:37:28 -0500 (EST) From: Stefan Monnier To: Jambunathan K Subject: Re: bug#13126: 24.3.50; (WISH) Document pcase in Info manual Message-ID: References: <87fw3fpoa6.fsf@gmail.com> <87txrslwjp.fsf@gmail.com> <87fw3a2dy2.fsf@gmail.com> Date: Thu, 13 Dec 2012 12:37:28 -0500 In-Reply-To: <87fw3a2dy2.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 13 Dec 2012 20:31:57 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4431=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4431> : streams <873689> : uri <1293285> X-Spam-Score: -0.9 (/) X-Debbugs-Envelope-To: 13126 Cc: 13126@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.7 (-) >>> Thanks. `pcase' seemed a good replacement for `case'. >> While it's not a plug-in replacement, it provides a superset of the >> features of case, yes. > pcase also reminds me of CL's case. Btw, you know in what version of > Emacs did pcase made it's appearance. Probably 24.1. You'd have to check the NEWS file. > Provide a BNF and document TERMINALS before NON-TERMINALS. (Currently it > seems other way round). I don't think a BNF spec has its place there. It's fine for the docstring, but the point of this lispref subsection is to give an introduction to `pcase'. > May be replace the example snippets with a /simple/ and /cohesive/ > example. Do you think snippet 1 is not sufficiently simple? > I found Snippet 2 "too abstract" and leaves a lot to the > imagination of the reader. For those readers not familiar enough with functional programming, I could tweak it, maybe replacing `call' and `fn' cases with `(neg ,x) and `(if ,t ,e1 ,e2)? Would that help? The problem I see with your snippets is that they're too long. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 05 14:47:41 2013 Received: (at control) by debbugs.gnu.org; 5 Jan 2013 19:47:41 +0000 Received: from localhost ([127.0.0.1]:45636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrZiW-00019F-JF for submit@debbugs.gnu.org; Sat, 05 Jan 2013 14:47:40 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:37588) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TrZiT-00019A-Vq for control@debbugs.gnu.org; Sat, 05 Jan 2013 14:47:38 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1TrZiF-0003rw-WF for control@debbugs.gnu.org; Sat, 05 Jan 2013 14:47:24 -0500 Date: Sat, 05 Jan 2013 14:47:23 -0500 Message-Id: Subject: control message for bug 12752 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) unmerge 12752 close 12752 24.3 From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 04 03:10:59 2013 Received: (at control) by debbugs.gnu.org; 4 Feb 2013 08:10:59 +0000 Received: from localhost ([127.0.0.1]:35145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U2H8l-0003YI-2J for submit@debbugs.gnu.org; Mon, 04 Feb 2013 03:10:59 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:39264) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U2H8i-0003YB-CM for control@debbugs.gnu.org; Mon, 04 Feb 2013 03:10:57 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1U2H7g-0008Ce-KM for control@debbugs.gnu.org; Mon, 04 Feb 2013 03:09:52 -0500 Date: Mon, 04 Feb 2013 03:09:52 -0500 Message-Id: Subject: control message for bug 13126 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) forcemerge 12752 13126 From unknown Sun Jun 22 03:56:26 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 04 Mar 2013 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator