mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 14:21:10 +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:
parent
6fca8730f7
commit
9f17d967c9
3 changed files with 24 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
@c -*-texinfo-*-
|
@c -*-texinfo-*-
|
||||||
@c This is part of the GNU Guile Reference Manual.
|
@c This is part of the GNU Guile Reference Manual.
|
||||||
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 2010,
|
@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.
|
@c See the file guile.texi for copying conditions.
|
||||||
|
|
||||||
@node Procedures
|
@node Procedures
|
||||||
|
@ -271,7 +271,25 @@ sense at certain points in the program, delimited by these
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} program-arguments-alist program [ip]
|
@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
|
Accessors for a representation of the arguments of a program, with both
|
||||||
names and types (ie. either required, optional or keywords)
|
names and types (ie. either required, optional or keywords)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; Guile VM program functions
|
;;; 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
|
;;; This library is free software; you can redistribute it and/or
|
||||||
;;; modify it under the terms of the GNU Lesser General Public
|
;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
rest? rest (1+ n)))
|
rest? rest (1+ n)))
|
||||||
(rest?
|
(rest?
|
||||||
(lp nreq req nopt opt
|
(lp nreq req nopt opt
|
||||||
#f (var-by-index n)
|
#f (var-by-index (+ n (length (arity:kw arity))))
|
||||||
(1+ n)))
|
(1+ n)))
|
||||||
(else
|
(else
|
||||||
`((required . ,(reverse req))
|
`((required . ,(reverse req))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;;;; session.test --- test suite for (ice-9 session) -*- scheme -*-
|
;;;; session.test --- test suite for (ice-9 session) -*- scheme -*-
|
||||||
;;;; Jose Antonio Ortega Ruiz <jao@gnu.org> -- August 2010
|
;;;; 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
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; 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)
|
(lambda* (a b #:optional o p #:key k l #:rest r) #f)
|
||||||
((required . (a b)) (optional . (o p))
|
((required . (a b)) (optional . (o p))
|
||||||
(keyword . ((#:k . 5) (#:l . 6))) (allow-other-keys? . #f)
|
(keyword . ((#:k . 5) (#:l . 6))) (allow-other-keys? . #f)
|
||||||
(rest . k)))
|
(rest . r)))
|
||||||
|
|
||||||
(pass-if "aok? is preserved"
|
(pass-if "aok? is preserved"
|
||||||
;; See <http://bugs.gnu.org/10938>.
|
;; See <http://bugs.gnu.org/10938>.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue