GNU bug report logs - #30144
[PATCH] doc: Document (ice-9 match) macros.

Previous Next

Package: guile;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Wed, 17 Jan 2018 12:26:01 UTC

Severity: normal

Tags: patch

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: tracker <at> debbugs.gnu.org
Subject: bug#30144: closed ([PATCH] doc: Document (ice-9 match) macros.)
Date: Mon, 18 Jun 2018 12:10:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 18 Jun 2018 14:08:48 +0200
with message-id <87vaaguwj3.fsf <at> gnu.org>
and subject line Re: bug#30144: [PATCH 1/1] doc: Document (ice-9 match) macros.
has caused the debbugs.gnu.org bug report #30144,
regarding [PATCH] doc: Document (ice-9 match) macros.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
30144: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=30144
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Arun Isaac <arunisaac <at> systemreboot.net>
To: bug-guile <at> gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: [PATCH] doc: Document (ice-9 match) macros.
Date: Wed, 17 Jan 2018 17:55:04 +0530
* 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



[Message part 3 (message/rfc822, inline)]
From: ludo <at> gnu.org (Ludovic Courtès)
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: mhw <at> netris.org, 30144-done <at> debbugs.gnu.org
Subject: Re: bug#30144: [PATCH 1/1] doc: Document (ice-9 match) macros.
Date: Mon, 18 Jun 2018 14:08:48 +0200
Hi Arun,

Arun Isaac <arunisaac <at> systemreboot.net> 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’.


This bug report was last modified 7 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.