David Kastrup <[email protected]> writes: > I'd have expected a pointer at least somewhere (if not everywhere) among > those links: > > <URL:http://www.gnu.org/software/guile/manual/html_node/Definition.html#Definition> > > <URL:http://www.gnu.org/software/guile/manual/html_node/Lambda-Alternatives.html#Lambda-Alternatives>
I agree, and have provided some documentation. I'm no texinfo expert so it probably needs cleanup. In particular, I wasn't sure of how to markup these curried forms. Comments kindly requested, -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"
>From 6addaedac96ffe919d1b0cb58ed9992fbd240bf7 Mon Sep 17 00:00:00 2001 From: Ian Price <[email protected]> Date: Tue, 4 Sep 2012 15:36:54 +0100 Subject: [PATCH] Document (ice-9 curried definitions) * doc/ref/Makefile.am(guile_TEXINFOS): Add curried.texi to list * doc/ref/curried.texi: New file. * doc/ref/guile.texi(Guile Modules): Add "Curried Definitions" to menu. * doc/ref/scheme-ideas.texi(Lambda Alternatives): Refer to "Curried Definitions" from the `define' section. --- doc/ref/Makefile.am | 1 + doc/ref/curried.texi | 53 +++++++++++++++++++++++++++++++++++++++++++++ doc/ref/guile.texi | 2 + doc/ref/scheme-ideas.texi | 5 ++++ 4 files changed, 61 insertions(+), 0 deletions(-) create mode 100644 doc/ref/curried.texi diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index abe9cb9..201ab6b 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -62,6 +62,7 @@ guile_TEXINFOS = preface.texi \ web.texi \ expect.texi \ scsh.texi \ + curried.texi \ sxml-match.texi \ scheme-scripts.texi \ api-overview.texi \ diff --git a/doc/ref/curried.texi b/doc/ref/curried.texi new file mode 100644 index 0000000..05475bd --- /dev/null +++ b/doc/ref/curried.texi @@ -0,0 +1,53 @@ +@c -*-texinfo-*- +@c This is part of the GNU Guile Reference Manual. +@c Copyright (C) 2012 +@c Free Software Foundation, Inc. +@c See the file guile.texi for copying conditions. + +@node Curried Definitions +@section Curried Definitions + +The macros in this section are provided by +@lisp +(use-modules (ice-9 curried-definitions)) +@end lisp +@noindent +and replace those provided by default. + +Prior to guile 2, guile provided a type of definition known colloquially +as a ``curried definition''. The idea is to extend the syntax of +@code{define} so that you can conveniently define procedures that return +procedures, up to any desired depth. + +For example, +@example +(define ((foo x) y) + (list x y)) +@end example +is a convenience form of +@example +(define foo + (lambda (x) + (lambda (y) + (list x y)))) +@end example + +@deffn {Syntax} define (@dots{} (name args @dots{}) @dots{}) expression @dots{} +A curried version of the default @code{define}. +@end deffn + +@deffn {Syntax} define* (@dots{} (name args @dots{}) @dots{}) expression @dots{} +A curried version of the default @code{define*}. Accepts all the options +@code{lambda*} does, for example, +@example +(define* ((foo #:keys (bar 'baz) (quux 'zot)) frotz #:rest rest) + (list bar quux frotz rest)) + +((foo #:quux 'foo) 1 2 3 4 5) +@result{} (baz foo 1 (2 3 4 5)) +@end example +@end deffn + +@deffn {Syntax} define-public (@dots{} (name args @dots{}) @dots{}) expression @dots{} +A curried version of the default @code{define-public}. +@end deffn diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index c3da0c3..a1b3fe6 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -370,6 +370,7 @@ available through both Scheme and C interfaces. * Expect:: Controlling interactive programs with Guile. * sxml-match:: Pattern matching of SXML. * The Scheme shell (scsh):: Using scsh interfaces in Guile. +* Curried Definitions:: Extended @code{define} syntax. @end menu @include slib.texi @@ -387,6 +388,7 @@ available through both Scheme and C interfaces. @include sxml-match.texi @include scsh.texi +@include curried.texi @node Standard Library @chapter Standard Library diff --git a/doc/ref/scheme-ideas.texi b/doc/ref/scheme-ideas.texi index 53f7b61..49297fd 100644 --- a/doc/ref/scheme-ideas.texi +++ b/doc/ref/scheme-ideas.texi @@ -476,6 +476,11 @@ The corresponding forms of the alternative @code{define} syntax are: @noindent For details on how these forms work, see @xref{Lambda}. +Prior to guile 2, guile provided an extension to @code{define} syntax +that allowed you to nest the previous extension up to an arbitrary +depth. These are no longer provided by default, and instead have been +moved to @ref{Curried Definitions} + (It could be argued that the alternative @code{define} forms are rather confusing, especially for newcomers to the Scheme language, as they hide both the role of @code{lambda} and the fact that procedures are values -- 1.7.7.6
