From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 17 Jan 2018 12:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 30144@debbugs.gnu.org Cc: Arun Isaac X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.151619195723252 (code B ref -1); Wed, 17 Jan 2018 12:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jan 2018 12:25:57 +0000 Received: from localhost ([127.0.0.1]:59513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebmmy-00062y-MV for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebmmw-00062g-V2 for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebmmm-00044n-QQ for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebmmm-00044O-N6 for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebmmf-0000C1-Im for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebmma-0003x3-Jn for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:37 -0500 Received: from vultr.systemreboot.net ([45.77.148.100]:49876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebmma-0003tv-0t for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FZPf1faRhaQrjzDRLgiCVjEfWeOL441M9rAfg6oSaWc=; b=K8LLeKwKXskKmQLO/r/KWFwOi4 5cRaRPMtyJctuzHJs9yO5KYrEwjB0qJQYapZagnPeaOEmaGNTpTHh0MLZH5ILNMlJCof/qn+y+2OY NvkcNRbvDx3yZ5mulZmVlgIB4/h+4rsfKCfhz/Jpd4Ot2tTaaU8qJPfqlitIq2LgWyOY=; Received: from [117.192.107.9] (helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90) (envelope-from ) id 1ebmmH-0006aQ-Np; Wed, 17 Jan 2018 17:55:13 +0530 From: Arun Isaac Date: Wed, 17 Jan 2018 17:55:04 +0530 Message-Id: <20180117122504.25583-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.15.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, match-let* and match-letrec. --- doc/ref/match.texi | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/doc/ref/match.texi b/doc/ref/match.texi index 12e3814ae..4d85fe3f9 100644 --- a/doc/ref/match.texi +++ b/doc/ref/match.texi @@ -213,8 +213,69 @@ any @var{person} whose second slot is a promise that evaluates to a one-element list containing a @var{person} whose first slot is @code{"Bob"}. -Please refer to the @code{ice-9/match.upstream.scm} file in your Guile -installation for more details. +The @code{(ice-9 match)} module also provides the following convenient +syntactic sugar macros wrapping around @code{match}. + +@deffn {Scheme Syntax} match-lambda exp clause1 clause2 @dots{} +Create a procedure of one argument that matches its argument against +each clause. + +@example +(match-lambda clause1 clause2 @dots{}) +@equiv{} +(lambda (arg) (match arg clause1 clause2 @dots{})) +@end example +@end deffn + +@deffn {Scheme Syntax} match-lambda* exp clause1 clause2 @dots{} +Create a procedure of any number of arguments that matches its argument +list against each clause. + +Equivalent to +@example +(match-lambda* clause1 clause2 @dots{}) +@equiv{} +(lambda args (match args clause1 clause2 @dots{})) +@end example +@end deffn + +@deffn {Scheme Syntax} match-let ((variable expression) @dots{}) body +Match each variable to the corresponding expression, and evaluate the +body with all matched variables in scope. Raise an error if any of the +expressions fail to match. @code{match-let} is analogous to named let +and can also be used for recursive functions which match on their +arguments as in @code{match-lambda*}. + +@example +(match-let (((x y) (list 1 2)) + ((a b) (list 3 4))) + (list a b x y)) +@result{} +(3 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-let* ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{let*}, match and +bind the variables in sequence, with preceding match variables in scope. + +@example +(match-let* (((x y) (list 1 2)) + ((a b) (list x 4))) + (list a b x y)) +@equiv{} +(match-let (((x y) (list 1 2))) + (match-let (((a b) (list x 4))) + (list a b x y))) +@result{} +(1 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-letrec ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{letrec}, match and +bind the variables with all match variables in scope. +@end deffn Guile also comes with a pattern matcher specifically tailored to SXML trees, @xref{sxml-match}. -- 2.15.1 From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 21 Jan 2018 16:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Arun Isaac Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.15165515551129 (code B ref 30144); Sun, 21 Jan 2018 16:20:01 +0000 Received: (at 30144) by debbugs.gnu.org; 21 Jan 2018 16:19:15 +0000 Received: from localhost ([127.0.0.1]:37223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edIKx-0000I8-F1 for submit@debbugs.gnu.org; Sun, 21 Jan 2018 11:19:15 -0500 Received: from world.peace.net ([50.252.239.5]:41642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edIKw-0000Hu-Gx for 30144@debbugs.gnu.org; Sun, 21 Jan 2018 11:19:14 -0500 Received: from [98.216.255.118] (helo=yeeloong) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1edIKq-0007rY-CQ; Sun, 21 Jan 2018 11:19:08 -0500 From: Mark H Weaver References: <20180117122504.25583-1-arunisaac@systemreboot.net> Date: Sun, 21 Jan 2018 11:16:45 -0500 In-Reply-To: <20180117122504.25583-1-arunisaac@systemreboot.net> (Arun Isaac's message of "Wed, 17 Jan 2018 17:55:04 +0530") Message-ID: <87shazmbki.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Arun, Arun Isaac writes: > * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, > match-let* and match-letrec. Modulo a few minor nits, which I'll describe in another message, this patch looks great to me! Would you be willing to assign the copyright to the Free Software Foundation, so that we could install it in Guile? If you agree, I'll follow up off-list. Thank you! Mark From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 21 Jan 2018 18:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Mark H Weaver Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.151655850419294 (code B ref 30144); Sun, 21 Jan 2018 18:16:01 +0000 Received: (at 30144) by debbugs.gnu.org; 21 Jan 2018 18:15:04 +0000 Received: from localhost ([127.0.0.1]:37320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edK92-000518-Hc for submit@debbugs.gnu.org; Sun, 21 Jan 2018 13:15:04 -0500 Received: from vultr.systemreboot.net ([45.77.148.100]:34186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edK8z-00050K-TX for 30144@debbugs.gnu.org; Sun, 21 Jan 2018 13:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oqECMbI0UjVCVYYNezwmfrzVWnXmdZYlXb2NwTlZtIU=; b=kgDVvcCXKOYYPZwM0vMbYDN9E JqiCLv8rFO2xCPiQzDwG7y6XTWPAGNTXiALtlivzF/odx240VsAWAxQB0hFwBEP9G+Ok9xHGmO3+J 10j6Nvguyc1PJS2q8SJEsOhIZi9VPkJXQji2kvYwv8OBr0r1pCdJf/UWFGUi3gNX/50gg=; Received: from [103.61.74.183] (helo=steel) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90) (envelope-from ) id 1edK8r-0005o9-1B; Sun, 21 Jan 2018 23:44:53 +0530 From: Arun Isaac In-Reply-To: <87shazmbki.fsf@netris.org> References: <20180117122504.25583-1-arunisaac@systemreboot.net> <87shazmbki.fsf@netris.org> Date: Sun, 21 Jan 2018 23:44:50 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Mark H Weaver writes: > Would you be willing to assign the copyright to the Free Software > Foundation, so that we could install it in Guile? Yes, sure. I'd be happy to assign copyright to the FSF. Let me know what I should do. From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 21 Feb 2018 22:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Mark H Weaver Cc: Arun Isaac , 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.151925176423325 (code B ref 30144); Wed, 21 Feb 2018 22:23:01 +0000 Received: (at 30144) by debbugs.gnu.org; 21 Feb 2018 22:22:44 +0000 Received: from localhost ([127.0.0.1]:55024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eocmi-000649-7t for submit@debbugs.gnu.org; Wed, 21 Feb 2018 17:22:44 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:43100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eocmf-00063s-HE for 30144@debbugs.gnu.org; Wed, 21 Feb 2018 17:22:43 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 1944E11B5D; Wed, 21 Feb 2018 23:22:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c3nlFtYj-3K0; Wed, 21 Feb 2018 23:22:40 +0100 (CET) Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465]) by hera.aquilenet.fr (Postfix) with ESMTPSA id E9D2C119A1; Wed, 21 Feb 2018 23:22:39 +0100 (CET) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180117122504.25583-1-arunisaac@systemreboot.net> <87shazmbki.fsf@netris.org> Date: Wed, 21 Feb 2018 23:22:39 +0100 In-Reply-To: <87shazmbki.fsf@netris.org> (Mark H. Weaver's message of "Sun, 21 Jan 2018 11:16:45 -0500") Message-ID: <877er6c79s.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Hi Mark, Mark H Weaver skribis: > Arun Isaac writes: > >> * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, >> match-let* and match-letrec. > > Modulo a few minor nits, which I'll describe in another message, this > patch looks great to me! Now that Arun=E2=80=99s assignment is on file, is there anything you=E2=80= =99d like to add to the patch? Or should we commit as is? Thanks, Ludo=E2=80=99. From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 16 Mar 2018 04:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Arun Isaac Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.15211732052472 (code B ref 30144); Fri, 16 Mar 2018 04:07:02 +0000 Received: (at 30144) by debbugs.gnu.org; 16 Mar 2018 04:06:45 +0000 Received: from localhost ([127.0.0.1]:35624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewgdf-0000dm-0W for submit@debbugs.gnu.org; Fri, 16 Mar 2018 00:06:44 -0400 Received: from world.peace.net ([50.252.239.5]:47852) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewgdc-0000dY-QG for 30144@debbugs.gnu.org; Fri, 16 Mar 2018 00:06:41 -0400 Received: from pool-72-93-30-18.bstnma.east.verizon.net ([72.93.30.18] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewgdW-0003Kq-Rj; Fri, 16 Mar 2018 00:06:35 -0400 From: Mark H Weaver References: <20180117122504.25583-1-arunisaac@systemreboot.net> Date: Fri, 16 Mar 2018 00:05:39 -0400 In-Reply-To: <20180117122504.25583-1-arunisaac@systemreboot.net> (Arun Isaac's message of "Wed, 17 Jan 2018 17:55:04 +0530") Message-ID: <87woyc4qcs.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Arun, I apologize for the long delay on this. This patch mostly looks great to me, but there are a few minor issues. Please see below for comments. Arun Isaac writes: > * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, > match-let* and match-letrec. > --- > doc/ref/match.texi | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 63 insertions(+), 2 deletions(-) > > diff --git a/doc/ref/match.texi b/doc/ref/match.texi > index 12e3814ae..4d85fe3f9 100644 > --- a/doc/ref/match.texi > +++ b/doc/ref/match.texi > @@ -213,8 +213,69 @@ any @var{person} whose second slot is a promise that evaluates to a > one-element list containing a @var{person} whose first slot is > @code{"Bob"}. > > -Please refer to the @code{ice-9/match.upstream.scm} file in your Guile > -installation for more details. > +The @code{(ice-9 match)} module also provides the following convenient > +syntactic sugar macros wrapping around @code{match}. > + > +@deffn {Scheme Syntax} match-lambda exp clause1 clause2 @dots{} > +Create a procedure of one argument that matches its argument against > +each clause. How about adding "and evaluates the corresponding expressions" or something like that? > + > +@example > +(match-lambda clause1 clause2 @dots{}) > +@equiv{} > +(lambda (arg) (match arg clause1 clause2 @dots{})) > +@end example It might be nicer to include an actual example here, rather than just showing the raw transformation. What do you think? > +@end deffn > + > +@deffn {Scheme Syntax} match-lambda* exp clause1 clause2 @dots{} > +Create a procedure of any number of arguments that matches its argument > +list against each clause. > + > +Equivalent to > +@example > +(match-lambda* clause1 clause2 @dots{}) > +@equiv{} > +(lambda args (match args clause1 clause2 @dots{})) > +@end example > +@end deffn My suggestions above for 'match-lambda' also apply to 'match-lambda*'. > + > +@deffn {Scheme Syntax} match-let ((variable expression) @dots{}) body "variable" here should be replaced with "pattern". In general, any pattern can go there. > +Match each variable to the corresponding expression, and evaluate the > +body with all matched variables in scope. Raise an error if any of the > +expressions fail to match. @code{match-let} is analogous to named let It's only analogous to a named let if a variable name is inserted immediately after 'match-let', before the clauses. In fact, the named-let case is not covered by the first line of your definition where you give the syntax. How about removing any mention of named-let in this definition, and then add a separate brief definition for the named-let variant of 'match-let'? It might be worthwhile to keep them separate given that their use cases and relevant examples are so different. What do you think? > +and can also be used for recursive functions which match on their > +arguments as in @code{match-lambda*}. > + > +@example > +(match-let (((x y) (list 1 2)) > + ((a b) (list 3 4))) There's a tab character in the line above, which causes things to not line up properly when looking at the diff. Could you convert tabs to spaces? In emacs, it can be done using M-x untabify. Would you like to send a revised patch? Mark From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 16 Mar 2018 04:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Arun Isaac Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.15211748585347 (code B ref 30144); Fri, 16 Mar 2018 04:35:01 +0000 Received: (at 30144) by debbugs.gnu.org; 16 Mar 2018 04:34:18 +0000 Received: from localhost ([127.0.0.1]:35657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewh4M-0001OA-0A for submit@debbugs.gnu.org; Fri, 16 Mar 2018 00:34:18 -0400 Received: from world.peace.net ([50.252.239.5]:48022) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewh4L-0001Nz-8T for 30144@debbugs.gnu.org; Fri, 16 Mar 2018 00:34:17 -0400 Received: from pool-72-93-30-18.bstnma.east.verizon.net ([72.93.30.18] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewh4F-0003oJ-Ff; Fri, 16 Mar 2018 00:34:11 -0400 From: Mark H Weaver References: <20180117122504.25583-1-arunisaac@systemreboot.net> <87woyc4qcs.fsf@netris.org> Date: Fri, 16 Mar 2018 00:33:16 -0400 In-Reply-To: <87woyc4qcs.fsf@netris.org> (Mark H. Weaver's message of "Fri, 16 Mar 2018 00:05:39 -0400") Message-ID: <87d1044p2r.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Mark H Weaver writes: > Arun Isaac writes: >> +@deffn {Scheme Syntax} match-lambda exp clause1 clause2 @dots{} >> +Create a procedure of one argument that matches its argument against >> +each clause. > > How about adding "and evaluates the corresponding expressions" or > something like that? It occurs to me that we should also document the return value. How about adding "and returns the result(s) of evaluating the corresponding expressions"? Mark From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 16 Mar 2018 23:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Mark H Weaver Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.152124285421781 (code B ref 30144); Fri, 16 Mar 2018 23:28:02 +0000 Received: (at 30144) by debbugs.gnu.org; 16 Mar 2018 23:27:34 +0000 Received: from localhost ([127.0.0.1]:37391 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewyl4-0005fF-1a for submit@debbugs.gnu.org; Fri, 16 Mar 2018 19:27:34 -0400 Received: from vultr.systemreboot.net ([45.77.148.100]:35046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewyl2-0005f1-2s for 30144@debbugs.gnu.org; Fri, 16 Mar 2018 19:27:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XLsxiNxY8Ac7Cpss71J+UcBvRcdH+MO0oocl+BI8ROM=; b=VsbeCCPFr6pyK442XXzzmflXh Isr8J1STxr0wSvLQlbxx7NNplTdeiZvfmzfVhbgSpsjhEmv/HX0ph+WGaZ4nDk/Uuh/4Hk5qhup18 IG18qC5AajbN8eQPM8cCcNmO/UMEwc2Zv3dCdPGXJB9p4qOMUdqX5EN0V5tIkKvW0cnUQ=; Received: from [61.3.26.0] (helo=steel) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ewyko-0001W1-Fl; Sat, 17 Mar 2018 04:57:18 +0530 From: Arun Isaac In-Reply-To: <87woyc4qcs.fsf@netris.org> References: <20180117122504.25583-1-arunisaac@systemreboot.net> <87woyc4qcs.fsf@netris.org> Date: Sat, 17 Mar 2018 04:57:17 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) >> +Match each variable to the corresponding expression, and evaluate the >> +body with all matched variables in scope. Raise an error if any of the >> +expressions fail to match. @code{match-let} is analogous to named let > > It's only analogous to a named let if a variable name is inserted > immediately after 'match-let', before the clauses. In fact, the > named-let case is not covered by the first line of your definition where > you give the syntax. > How about removing any mention of named-let in this definition, and then > add a separate brief definition for the named-let variant of > 'match-let'? It might be worthwhile to keep them separate given that > their use cases and relevant examples are so different. What do you > think? I have made all the other changes except this one. I have never used match-let analogous to a named let, and am unable to get a working example. If you could show me a working example, I'll add it to the new patch. I'll send you the revised patch once we decide on the above. Thanks! From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH] doc: Document (ice-9 match) macros. Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 20 Mar 2018 00:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Arun Isaac Cc: 30144@debbugs.gnu.org Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.152150599015757 (code B ref 30144); Tue, 20 Mar 2018 00:34:02 +0000 Received: (at 30144) by debbugs.gnu.org; 20 Mar 2018 00:33:10 +0000 Received: from localhost ([127.0.0.1]:42390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey5DB-000465-VH for submit@debbugs.gnu.org; Mon, 19 Mar 2018 20:33:10 -0400 Received: from world.peace.net ([50.252.239.5]:33766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey5D9-00045Z-09 for 30144@debbugs.gnu.org; Mon, 19 Mar 2018 20:33:08 -0400 Received: from pool-72-93-34-155.bstnma.east.verizon.net ([72.93.34.155] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ey5D2-0003jY-Km; Mon, 19 Mar 2018 20:33:00 -0400 From: Mark H Weaver References: <20180117122504.25583-1-arunisaac@systemreboot.net> <87woyc4qcs.fsf@netris.org> Date: Mon, 19 Mar 2018 20:32:12 -0400 In-Reply-To: (Arun Isaac's message of "Sat, 17 Mar 2018 04:57:17 +0530") Message-ID: <87zi33bn8z.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Arun, Arun Isaac writes: >>> +Match each variable to the corresponding expression, and evaluate the >>> +body with all matched variables in scope. Raise an error if any of the >>> +expressions fail to match. @code{match-let} is analogous to named let >> >> It's only analogous to a named let if a variable name is inserted >> immediately after 'match-let', before the clauses. In fact, the >> named-let case is not covered by the first line of your definition where >> you give the syntax. > >> How about removing any mention of named-let in this definition, and then >> add a separate brief definition for the named-let variant of >> 'match-let'? It might be worthwhile to keep them separate given that >> their use cases and relevant examples are so different. What do you >> think? > > I have made all the other changes except this one. I have never used > match-let analogous to a named let, and am unable to get a working > example. If you could show me a working example, I'll add it to the new > patch. > > I'll send you the revised patch once we decide on the above. Thanks! I thought about it, and I can't easily think of a good use for named 'match-let'. Any recursion needs a base case, which requires at least two cases in the match, but 'match-let' does not allow for multiple cases for its matches. How about if we omit an example for named 'match-let', and simply say something like: @deffn {Scheme Syntax} match-let variable ((pattern init) @dots{}) body Similar to @code{match-let}, but analogously to @dfn{named let}, locally bind VARIABLE to a new procedure which accepts as many arguments as there are INIT expressions. The procedure is initially applied to the results of evaluating the INIT expressions. When called, the procedure matches each argument against the corresponding PATTERN, and returns the result(s) of evaluating the BODY expressions. @xref{while do, Iteration} for more on @dfn{named let}. Thanks! Mark From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH 0/1] Document (ice-9 match) macros References: <20180117122504.25583-1-arunisaac@systemreboot.net> In-Reply-To: <20180117122504.25583-1-arunisaac@systemreboot.net> Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 23 Mar 2018 14:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 30144@debbugs.gnu.org Cc: mhw@netris.org, Arun Isaac Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.152181495620172 (code B ref 30144); Fri, 23 Mar 2018 14:23:02 +0000 Received: (at 30144) by debbugs.gnu.org; 23 Mar 2018 14:22:36 +0000 Received: from localhost ([127.0.0.1]:49832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezNaW-0005FI-21 for submit@debbugs.gnu.org; Fri, 23 Mar 2018 10:22:36 -0400 Received: from vultr.systemreboot.net ([45.77.148.100]:59990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezNaU-0005F4-8q for 30144@debbugs.gnu.org; Fri, 23 Mar 2018 10:22:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q0UyC5ziXZrqo2LeKjLBsQWwghLcIuEMlGmn+I6PJ0c=; b=SmXwKLkslcX93haMKy80cUzwvC bK4eWBVMQG0r9+FKZMmozw+Gbs7UZHQfFSdNUm3rIIBAZWnYf5Q4PSXQeS8lKz2WJeRuJR0b4j1F9 0ApMlaWy4uLHxAkmHttH97VSfRrkl7KISAF3iPhKWebUT7OO4cLns8rhTLdgmapq83So=; Received: from [117.192.124.137] (helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ezNaL-0007f4-4E; Fri, 23 Mar 2018 19:52:25 +0530 From: Arun Isaac Date: Fri, 23 Mar 2018 19:52:03 +0530 Message-Id: <20180323142204.23420-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.15.1 X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi, I have made all the changes you suggested. Patch follows. Thanks. Arun Isaac (1): doc: Document (ice-9 match) macros. doc/ref/match.texi | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) -- 2.15.1 From unknown Sat Jul 26 21:32:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30144: [PATCH 1/1] doc: Document (ice-9 match) macros. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 23 Mar 2018 14:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30144 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 30144@debbugs.gnu.org Cc: mhw@netris.org, Arun Isaac Received: via spool by 30144-submit@debbugs.gnu.org id=B30144.152181496620196 (code B ref 30144); Fri, 23 Mar 2018 14:23:02 +0000 Received: (at 30144) by debbugs.gnu.org; 23 Mar 2018 14:22:46 +0000 Received: from localhost ([127.0.0.1]:49835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezNag-0005Fg-8P for submit@debbugs.gnu.org; Fri, 23 Mar 2018 10:22:46 -0400 Received: from vultr.systemreboot.net ([45.77.148.100]:59998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezNae-0005FR-6Z for 30144@debbugs.gnu.org; Fri, 23 Mar 2018 10:22:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JL3BSAGhHWXbCgNjP2YFatP4zfhKJZ6vEWBt1QCpevY=; b=QednUtFzoiX7uvsv8tUcoEA67 V2rYlIKntX86CDDfQjdI9tU/4lRZOumOuPTrVf8Z7zgm+GheAQw/DDnsraqBjlEkTXEBm2lLOl6jE LkSVH0qVtmlTw/CmfyQhB9yWvAkwFPpmwq70sJBHhTupxuMkpBoWj0QRWFlG1f6L4Msuk=; Received: from [117.192.124.137] (helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ezNaW-0007f4-Rc; Fri, 23 Mar 2018 19:52:36 +0530 From: Arun Isaac Date: Fri, 23 Mar 2018 19:52:04 +0530 Message-Id: <20180323142204.23420-2-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180323142204.23420-1-arunisaac@systemreboot.net> References: <20180323142204.23420-1-arunisaac@systemreboot.net> X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, match-let* and match-letrec. --- doc/ref/match.texi | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/doc/ref/match.texi b/doc/ref/match.texi index 12e3814ae..0fc5105d1 100644 --- a/doc/ref/match.texi +++ b/doc/ref/match.texi @@ -213,8 +213,96 @@ any @var{person} whose second slot is a promise that evaluates to a one-element list containing a @var{person} whose first slot is @code{"Bob"}. -Please refer to the @code{ice-9/match.upstream.scm} file in your Guile -installation for more details. +The @code{(ice-9 match)} module also provides the following convenient +syntactic sugar macros wrapping around @code{match}. + +@deffn {Scheme Syntax} match-lambda exp clause1 clause2 @dots{} +Create a procedure of one argument that matches its argument against +each clause, and returns the result of evaluating the corresponding +expressions. + +@example +(match-lambda clause1 clause2 @dots{}) +@equiv{} +(lambda (arg) (match arg clause1 clause2 @dots{})) +@end example +@end deffn + +@example +((match-lambda + (('hello (who)) + who)) + '(hello (world))) +@result{} world +@end example + +@deffn {Scheme Syntax} match-lambda* exp clause1 clause2 @dots{} +Create a procedure of any number of arguments that matches its argument +list against each clause, and returns the result of evaluating the +corresponding expressions. + +@example +(match-lambda* clause1 clause2 @dots{}) +@equiv{} +(lambda args (match args clause1 clause2 @dots{})) +@end example +@end deffn + +@example +((match-lambda* + (('hello (who)) + who)) + 'hello '(world)) +@result{} world +@end example + +@deffn {Scheme Syntax} match-let ((pattern expression) @dots{}) body +Match each pattern to the corresponding expression, and evaluate the +body with all matched variables in scope. Raise an error if any of the +expressions fail to match. @code{match-let} is analogous to named let +and can also be used for recursive functions which match on their +arguments as in @code{match-lambda*}. + +@example +(match-let (((x y) (list 1 2)) + ((a b) (list 3 4))) + (list a b x y)) +@result{} +(3 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-let variable ((pattern init) @dots{}) body +Similar to @code{match-let}, but analogously to @dfn{named let}, locally +bind VARIABLE to a new procedure which accepts as many arguments as +there are INIT expressions. The procedure is initially applied to the +results of evaluating the INIT expressions. When called, the procedure +matches each argument against the corresponding PATTERN, and returns the +result(s) of evaluating the BODY expressions. @xref{while do, +Iteration}, for more on @dfn{named let}. +@end deffn + +@deffn {Scheme Syntax} match-let* ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{let*}, match and +bind the variables in sequence, with preceding match variables in scope. + +@example +(match-let* (((x y) (list 1 2)) + ((a b) (list x 4))) + (list a b x y)) +@equiv{} +(match-let (((x y) (list 1 2))) + (match-let (((a b) (list x 4))) + (list a b x y))) +@result{} +(1 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-letrec ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{letrec}, match and +bind the variables with all match variables in scope. +@end deffn Guile also comes with a pattern matcher specifically tailored to SXML trees, @xref{sxml-match}. -- 2.15.1 From unknown Sat Jul 26 21:32:19 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Arun Isaac Subject: bug#30144: closed (Re: bug#30144: [PATCH 1/1] doc: Document (ice-9 match) macros.) Message-ID: References: <87vaaguwj3.fsf@gnu.org> <20180117122504.25583-1-arunisaac@systemreboot.net> X-Gnu-PR-Message: they-closed 30144 X-Gnu-PR-Package: guile X-Gnu-PR-Keywords: patch Reply-To: 30144@debbugs.gnu.org Date: Mon, 18 Jun 2018 12:10:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1529323802-30987-1" This is a multi-part message in MIME format... ------------=_1529323802-30987-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #30144: [PATCH] doc: Document (ice-9 match) macros. which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 30144@debbugs.gnu.org. --=20 30144: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D30144 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1529323802-30987-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 30144-done) by debbugs.gnu.org; 18 Jun 2018 12:09:19 +0000 Received: from localhost ([127.0.0.1]:54462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUsyF-00082n-2v for submit@debbugs.gnu.org; Mon, 18 Jun 2018 08:09:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48907) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUsyD-00082a-3M for 30144-done@debbugs.gnu.org; Mon, 18 Jun 2018 08:09:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUsy3-0003TJ-4Y for 30144-done@debbugs.gnu.org; Mon, 18 Jun 2018 08:09:12 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37003) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUsxm-0003H8-V7; Mon, 18 Jun 2018 08:08:51 -0400 Received: from [193.50.110.191] (port=59338 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fUsxm-0006r8-HG; Mon, 18 Jun 2018 08:08:50 -0400 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Arun Isaac Subject: Re: bug#30144: [PATCH 1/1] doc: Document (ice-9 match) macros. References: <20180323142204.23420-1-arunisaac@systemreboot.net> <20180323142204.23420-2-arunisaac@systemreboot.net> Date: Mon, 18 Jun 2018 14:08:48 +0200 In-Reply-To: <20180323142204.23420-2-arunisaac@systemreboot.net> (Arun Isaac's message of "Fri, 23 Mar 2018 19:52:04 +0530") Message-ID: <87vaaguwj3.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 30144-done Cc: mhw@netris.org, 30144-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hi Arun, Arun Isaac skribis: > * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, > match-let* and match-letrec. Finally applied. Thanks for improving the manual! Ludo=E2=80=99. ------------=_1529323802-30987-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 17 Jan 2018 12:25:57 +0000 Received: from localhost ([127.0.0.1]:59513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebmmy-00062y-MV for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebmmw-00062g-V2 for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebmmm-00044n-QQ for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebmmm-00044O-N6 for submit@debbugs.gnu.org; Wed, 17 Jan 2018 07:25:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebmmf-0000C1-Im for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebmma-0003x3-Jn for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:37 -0500 Received: from vultr.systemreboot.net ([45.77.148.100]:49876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebmma-0003tv-0t for bug-guile@gnu.org; Wed, 17 Jan 2018 07:25:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FZPf1faRhaQrjzDRLgiCVjEfWeOL441M9rAfg6oSaWc=; b=K8LLeKwKXskKmQLO/r/KWFwOi4 5cRaRPMtyJctuzHJs9yO5KYrEwjB0qJQYapZagnPeaOEmaGNTpTHh0MLZH5ILNMlJCof/qn+y+2OY NvkcNRbvDx3yZ5mulZmVlgIB4/h+4rsfKCfhz/Jpd4Ot2tTaaU8qJPfqlitIq2LgWyOY=; Received: from [117.192.107.9] (helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90) (envelope-from ) id 1ebmmH-0006aQ-Np; Wed, 17 Jan 2018 17:55:13 +0530 From: Arun Isaac To: bug-guile@gnu.org Subject: [PATCH] doc: Document (ice-9 match) macros. Date: Wed, 17 Jan 2018 17:55:04 +0530 Message-Id: <20180117122504.25583-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.15.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: Arun Isaac X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) * doc/ref/match.texi: Document match-lambda, match-lambda*, match-let, match-let* and match-letrec. --- doc/ref/match.texi | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/doc/ref/match.texi b/doc/ref/match.texi index 12e3814ae..4d85fe3f9 100644 --- a/doc/ref/match.texi +++ b/doc/ref/match.texi @@ -213,8 +213,69 @@ any @var{person} whose second slot is a promise that evaluates to a one-element list containing a @var{person} whose first slot is @code{"Bob"}. -Please refer to the @code{ice-9/match.upstream.scm} file in your Guile -installation for more details. +The @code{(ice-9 match)} module also provides the following convenient +syntactic sugar macros wrapping around @code{match}. + +@deffn {Scheme Syntax} match-lambda exp clause1 clause2 @dots{} +Create a procedure of one argument that matches its argument against +each clause. + +@example +(match-lambda clause1 clause2 @dots{}) +@equiv{} +(lambda (arg) (match arg clause1 clause2 @dots{})) +@end example +@end deffn + +@deffn {Scheme Syntax} match-lambda* exp clause1 clause2 @dots{} +Create a procedure of any number of arguments that matches its argument +list against each clause. + +Equivalent to +@example +(match-lambda* clause1 clause2 @dots{}) +@equiv{} +(lambda args (match args clause1 clause2 @dots{})) +@end example +@end deffn + +@deffn {Scheme Syntax} match-let ((variable expression) @dots{}) body +Match each variable to the corresponding expression, and evaluate the +body with all matched variables in scope. Raise an error if any of the +expressions fail to match. @code{match-let} is analogous to named let +and can also be used for recursive functions which match on their +arguments as in @code{match-lambda*}. + +@example +(match-let (((x y) (list 1 2)) + ((a b) (list 3 4))) + (list a b x y)) +@result{} +(3 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-let* ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{let*}, match and +bind the variables in sequence, with preceding match variables in scope. + +@example +(match-let* (((x y) (list 1 2)) + ((a b) (list x 4))) + (list a b x y)) +@equiv{} +(match-let (((x y) (list 1 2))) + (match-let (((a b) (list x 4))) + (list a b x y))) +@result{} +(1 4 1 2) +@end example +@end deffn + +@deffn {Scheme Syntax} match-letrec ((variable expression) @dots{}) body +Similar to @code{match-let}, but analogously to @code{letrec}, match and +bind the variables with all match variables in scope. +@end deffn Guile also comes with a pattern matcher specifically tailored to SXML trees, @xref{sxml-match}. -- 2.15.1 ------------=_1529323802-30987-1--