summaryrefslogtreecommitdiff
path: root/module/srfi/srfi-9.scm
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2011-03-09 21:36:54 +0100
committerLudovic Courtès <ludo@gnu.org>2011-03-09 21:36:54 +0100
commit531c9f1dc51c4801c4d031ee80a31f15285a6b85 (patch)
tree04ec2bc4a3be0bb154494353e2806f0d4b861227 /module/srfi/srfi-9.scm
parentc428e58681fbd006d253bda51b3543110b317b8d (diff)
downloadguile-531c9f1dc51c4801c4d031ee80a31f15285a6b85.tar.gz
Don't mix definitions and expressions in SRFI-9
The expansion of `define-inlinable' contained an expression, which made SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition used in expression context"). * module/srfi/srfi-9.scm (define-inlinable): Get rid of apparently useless expression in the expansion, so the expansion yields only definitions. At the same time, use a space in the generated names to lessen the chances of name conflicts, also avoiding -Wunused-toplevel warnings. * test-suite/tests/srfi-9.test (non-toplevel): New test verifying that `define-record-type' works in non-toplevel context as well. * doc/ref/srfi-modules.texi (SRFI-9 - define-record-type): Add subsubsection noting that Guile does not enforce top-levelness. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'module/srfi/srfi-9.scm')
-rw-r--r--module/srfi/srfi-9.scm8
1 files changed, 5 insertions, 3 deletions
diff --git a/module/srfi/srfi-9.scm b/module/srfi/srfi-9.scm
index 80c3b60e8..fad570b26 100644
--- a/module/srfi/srfi-9.scm
+++ b/module/srfi/srfi-9.scm
@@ -1,6 +1,6 @@
;;; srfi-9.scm --- define-record-type
-;; Copyright (C) 2001, 2002, 2006, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -69,9 +69,12 @@
;; the macro expansion, whereas references in non-call contexts refer to
;; the procedure. Inspired by the `define-integrable' macro by Dybvig et al.
(lambda (x)
+ ;; Use a space in the prefix to avoid potential -Wunused-toplevel
+ ;; warning
+ (define prefix (string->symbol "% "))
(define (make-procedure-name name)
(datum->syntax name
- (symbol-append '% (syntax->datum name)
+ (symbol-append prefix (syntax->datum name)
'-procedure)))
(syntax-case x ()
@@ -81,7 +84,6 @@
#`(begin
(define (proc-name formals ...)
body ...)
- proc-name ;; unused
(define-syntax name
(lambda (x)
(syntax-case x ()