summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-01-07 22:02:26 +0100
committerAndy Wingo <wingo@pobox.com>2013-01-07 22:02:26 +0100
commit9f17d967c9b108f856776c035462e93017a6e7e2 (patch)
tree499037548c7923880f0ec5415c810550a3ba6c62
parent6fca8730f768429b31906104635cb5501e7e3df4 (diff)
downloadguile-9f17d967c9b108f856776c035462e93017a6e7e2.tar.gz
More procedure-arguments-alist documentation and a bugfix
* doc/ref/api-procedures.texi (Compiled Procedures): Expand program-arguments-alist and program-lambda-list documentation. * module/system/vm/program.scm (arity->arguments-alist): Fix the rest arg if there are also keyword args, a bug found while documenting! * test-suite/tests/session.test ("procedure-arguments"): Update.
-rw-r--r--doc/ref/api-procedures.texi22
-rw-r--r--module/system/vm/program.scm4
-rw-r--r--test-suite/tests/session.test4
3 files changed, 24 insertions, 6 deletions
diff --git a/doc/ref/api-procedures.texi b/doc/ref/api-procedures.texi
index baa47cc71..d77a2bdcc 100644
--- a/doc/ref/api-procedures.texi
+++ b/doc/ref/api-procedures.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010,
-@c 2011, 2012 Free Software Foundation, Inc.
+@c 2011, 2012, 2013 Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Procedures
@@ -271,7 +271,25 @@ sense at certain points in the program, delimited by these
@end deffn
@deffn {Scheme Procedure} program-arguments-alist program [ip]
-@deffnx {Scheme Procedure} program-lambda-list [ip]
+Return an association list describing the arguments that @var{program} accepts, or
+@code{#f} if the information cannot be obtained.
+
+For example:
+@example
+(program-arguments-alist
+ (lambda* (a b #:optional c #:key (d 1) #:rest e)
+ #t)) @result{}
+((required . (a b))
+ (optional . (c))
+ (keyword . ((#:d . 4)))
+ (allow-other-keys? . #f)
+ (rest . d))
+@end example
+
+The alist keys that are currently defined are `required', `optional',
+`keyword', `allow-other-keys?', and `rest'.
+
+@deffnx {Scheme Procedure} program-lambda-list program [ip]
Accessors for a representation of the arguments of a program, with both
names and types (ie. either required, optional or keywords)
diff --git a/module/system/vm/program.scm b/module/system/vm/program.scm
index d4de3356b..1d0100180 100644
--- a/module/system/vm/program.scm
+++ b/module/system/vm/program.scm
@@ -1,6 +1,6 @@
;;; Guile VM program functions
-;;; Copyright (C) 2001, 2009, 2010 Free Software Foundation, Inc.
+;;; Copyright (C) 2001, 2009, 2010, 2013 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
@@ -227,7 +227,7 @@
rest? rest (1+ n)))
(rest?
(lp nreq req nopt opt
- #f (var-by-index n)
+ #f (var-by-index (+ n (length (arity:kw arity))))
(1+ n)))
(else
`((required . ,(reverse req))
diff --git a/test-suite/tests/session.test b/test-suite/tests/session.test
index ec992f1c8..c9aa4a06c 100644
--- a/test-suite/tests/session.test
+++ b/test-suite/tests/session.test
@@ -1,7 +1,7 @@
;;;; session.test --- test suite for (ice-9 session) -*- scheme -*-
;;;; Jose Antonio Ortega Ruiz <jao@gnu.org> -- August 2010
;;;;
-;;;; Copyright (C) 2010, 2012 Free Software Foundation, Inc.
+;;;; Copyright (C) 2010, 2012, 2013 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
@@ -88,7 +88,7 @@
(lambda* (a b #:optional o p #:key k l #:rest r) #f)
((required . (a b)) (optional . (o p))
(keyword . ((#:k . 5) (#:l . 6))) (allow-other-keys? . #f)
- (rest . k)))
+ (rest . r)))
(pass-if "aok? is preserved"
;; See <http://bugs.gnu.org/10938>.