From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: bug#12341: define does not support lambda shorthand notation, define-public does Date: Tue, 04 Sep 2012 15:37:50 +0100 Message-ID: <87r4qham69.fsf@Kagami.home> References: <87ligrhti2.fsf@fencepost.gnu.org> <87zk56onnn.fsf@gnu.org> <87vcfu9dws.fsf@Kagami.home> <87vcfudkxh.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1346769556 13770 80.91.229.3 (4 Sep 2012 14:39:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Sep 2012 14:39:16 +0000 (UTC) Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 12341@debbugs.gnu.org To: David Kastrup Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Sep 04 16:39:16 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T8uHa-0003Bm-5o for guile-bugs@m.gmane.org; Tue, 04 Sep 2012 16:39:14 +0200 Original-Received: from localhost ([::1]:58577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uHX-0001Qf-Dv for guile-bugs@m.gmane.org; Tue, 04 Sep 2012 10:39:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uHU-0001Nh-VW for bug-guile@gnu.org; Tue, 04 Sep 2012 10:39:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8uHO-0007fb-AW for bug-guile@gnu.org; Tue, 04 Sep 2012 10:39:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uHO-0007fT-6b for bug-guile@gnu.org; Tue, 04 Sep 2012 10:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1T8uHO-0000T2-TD for bug-guile@gnu.org; Tue, 04 Sep 2012 10:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ian Price Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 04 Sep 2012 14:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12341 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 12341-submit@debbugs.gnu.org id=B12341.13467694901738 (code B ref 12341); Tue, 04 Sep 2012 14:39:02 +0000 Original-Received: (at 12341) by debbugs.gnu.org; 4 Sep 2012 14:38:10 +0000 Original-Received: from localhost ([127.0.0.1]:38558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8uGX-0000Ry-To for submit@debbugs.gnu.org; Tue, 04 Sep 2012 10:38:10 -0400 Original-Received: from mail-wg0-f46.google.com ([74.125.82.46]:59436) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8uGP-0000RS-VM for 12341@debbugs.gnu.org; Tue, 04 Sep 2012 10:38:06 -0400 Original-Received: by wgi16 with SMTP id 16so4541497wgi.15 for <12341@debbugs.gnu.org>; Tue, 04 Sep 2012 07:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=dQudbpi7XLS654Wwa9cNOF8U5NyPgAYLMaa8mdRULX4=; b=JNsYoKgMmOKHMH+S/SeZpOIqj8ckLQRRbta+0y/YmGQJASP34NV6f7Jr0MI9MlOqcZ E7+/phJ0SxP7DSxWYKsN4y5CIGwonXcQatkr3NU6KRy7cQgDY6gEui76vUKIpbxIh11Q BpMHUq3VSNpicp+p7dlMscOAONQ66gdnkZadfZqzb6/faJDaaFo8kzaLhQJVk+jwx0o4 xtueWMLhFGgNagY+io8Smv5TkqigcO3ghPVmo0/PbQ3QnRjqiIJBN8GRlnbPPp9ENyCH vOkABDFAoH+PCVUesCXKESiGrOAEUzFNm8pMV/xzeSg4gb/e7CS5L+LiWt+M9KHgyqqe 3UGA== Original-Received: by 10.180.103.4 with SMTP id fs4mr31204498wib.16.1346769478455; Tue, 04 Sep 2012 07:37:58 -0700 (PDT) Original-Received: from Kagami.home (host86-128-178-54.range86-128.btcentralplus.com. [86.128.178.54]) by mx.google.com with ESMTPS id eu4sm24665779wib.2.2012.09.04.07.37.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 07:37:57 -0700 (PDT) In-Reply-To: <87vcfudkxh.fsf@fencepost.gnu.org> (David Kastrup's message of "Tue, 04 Sep 2012 14:36:26 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6522 Archived-At: --=-=-= David Kastrup writes: > I'd have expected a pointer at least somewhere (if not everywhere) among > those links: > > > > 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" --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Document-ice-9-curried-definitions.patch Content-Description: curried define docs >From 6addaedac96ffe919d1b0cb58ed9992fbd240bf7 Mon Sep 17 00:00:00 2001 From: Ian Price 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 --=-=-=--