Subject: bug#12341: define does not support lambda shorthand notation, define-public does

From: Ian Price <[email-masked]>
Date: Tue, 04 Sep 2012 13:21:39 +0100

[email-masked] (Ludovic Courtès) writes:

> I’m inclined to live with the inconsistency, but I’m open to
> suggestions.
A quick git grep doesn't show any uses of curried define-public in the
guile code base, so the fix is pretty simple. I'm open to better
approaches though, since it does duplicate code, though this code is IMO
trivial.

-- 
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 fb23b4a49e9c1f5c15ef0ceb2ee1903ebfddd71a Mon Sep 17 00:00:00 2001
From: Ian Price <[email-masked]>
Date: Tue, 4 Sep 2012 13:18:58 +0100
Subject: [PATCH] `define-public' is no a longer curried definition by
 default.

* module/ice-9/boot-9.scm (define-public): Remove currying functionality.
* module/ice-9/curried-definitions.scm (define-public): New export.
---
 module/ice-9/boot-9.scm              |    4 +++-
 module/ice-9/curried-definitions.scm |   14 +++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 5ed543a..cf8252a 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3321,7 +3321,9 @@ module '(ice-9 q) '(make-q q-length))}."
 (define-syntax define-public
   (syntax-rules ()
     ((_ (name . args) . body)
-     (define-public name (lambda args . body)))
+     (begin
+       (define name (lambda args . body))
+       (export name)))
     ((_ name val)
      (begin
        (define name val)
diff --git a/module/ice-9/curried-definitions.scm b/module/ice-9/curried-definitions.scm
index d55f1fb..8c684a1 100644
--- a/module/ice-9/curried-definitions.scm
+++ b/module/ice-9/curried-definitions.scm
@@ -16,7 +16,8 @@
 
 (define-module (ice-9 curried-definitions)
   #:replace ((cdefine . define)
-             (cdefine* . define*)))
+             (cdefine* . define*)
+             define-public))
 
 (define-syntax cdefine
   (syntax-rules ()
@@ -39,3 +40,14 @@
        (lambda* rest body body* ...)))
     ((_ . rest)
      (define* . rest))))
+
+(define-syntax define-public
+  (syntax-rules ()
+    ((_ (name . args) . body)
+     (begin
+       (cdefine (name . args) . body)
+       (export name)))
+    ((_ name val)
+     (begin
+       (define name val)
+       (export name)))))
-- 
1.7.7.6