1@c -*-texinfo-*- 2@c This is part of the GNU Guile Reference Manual. 3@c Copyright (C) 2012 Free Software Foundation, Inc. 4@c See the file guile.texi for copying conditions. 5 6@node Curried Definitions 7@section Curried Definitions 8 9The macros in this section are provided by 10@lisp 11(use-modules (ice-9 curried-definitions)) 12@end lisp 13@noindent 14and replace those provided by default. 15 16Prior to Guile 2.0, Guile provided a type of definition known colloquially 17as a ``curried definition''. The idea is to extend the syntax of 18@code{define} so that you can conveniently define procedures that return 19procedures, up to any desired depth. 20 21For example, 22@example 23(define ((foo x) y) 24 (list x y)) 25@end example 26is a convenience form of 27@example 28(define foo 29 (lambda (x) 30 (lambda (y) 31 (list x y)))) 32@end example 33 34@deffn {Scheme Syntax} define (@dots{} (name args @dots{}) @dots{}) body @dots{} 35@deffnx {Scheme Syntax} define* (@dots{} (name args @dots{}) @dots{}) body @dots{} 36@deffnx {Scheme Syntax} define-public (@dots{} (name args @dots{}) @dots{}) body @dots{} 37 38Create a top level variable @var{name} bound to the procedure with 39parameter list @var{args}. If @var{name} is itself a formal parameter 40list, then a higher order procedure is created using that 41formal-parameter list, and returning a procedure that has parameter list 42@var{args}. This nesting may occur to arbitrary depth. 43 44@code{define*} is similar but the formal parameter lists take additional 45options as described in @ref{lambda* and define*}. For example, 46@example 47(define* ((foo #:keys (bar 'baz) (quux 'zot)) frotz #:rest rest) 48 (list bar quux frotz rest)) 49 50((foo #:quux 'foo) 1 2 3 4 5) 51@result{} (baz foo 1 (2 3 4 5)) 52@end example 53 54@code{define-public} is similar to @code{define} but it also adds 55@var{name} to the list of exported bindings of the current module. 56@end deffn 57