1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

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.
This commit is contained in:
Andy Wingo 2013-01-07 22:02:26 +01:00
parent 6fca8730f7
commit 9f17d967c9
3 changed files with 24 additions and 6 deletions

View file

@ -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)

View file

@ -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))

View file

@ -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>.