2012-07-01 17:32:03 +02:00
|
|
|
|
;;;; Copyright (C) 1997, 2000, 2001, 2003, 2006, 2009, 2010, 2011,
|
2013-11-08 13:29:03 +01:00
|
|
|
|
;;;; 2012, 2013 Free Software Foundation, Inc.
|
2001-04-28 00:32:23 +00:00
|
|
|
|
;;;;
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
|
|
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
;;;; License as published by the Free Software Foundation; either
|
2009-06-17 00:22:09 +01:00
|
|
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;;
|
|
|
|
|
|
;;;; This library is distributed in the hope that it will be useful,
|
1997-08-18 20:02:22 +00:00
|
|
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
;;;; Lesser General Public License for more details.
|
|
|
|
|
|
;;;;
|
|
|
|
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
;;;; License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-06-03 23:29:45 +00:00
|
|
|
|
;;;;
|
1997-08-18 20:02:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
1999-03-16 03:09:44 +00:00
|
|
|
|
(define-module (ice-9 session)
|
2011-12-12 23:42:04 +01:00
|
|
|
|
#:use-module (ice-9 documentation)
|
|
|
|
|
|
#:use-module (ice-9 regex)
|
|
|
|
|
|
#:use-module (ice-9 rdelim)
|
2012-07-01 17:32:03 +02:00
|
|
|
|
#:use-module (ice-9 match)
|
2011-12-12 23:42:04 +01:00
|
|
|
|
#:export (help
|
|
|
|
|
|
add-value-help-handler! remove-value-help-handler!
|
|
|
|
|
|
add-name-help-handler! remove-name-help-handler!
|
|
|
|
|
|
apropos-hook
|
|
|
|
|
|
apropos apropos-internal apropos-fold apropos-fold-accessible
|
|
|
|
|
|
apropos-fold-exported apropos-fold-all source arity
|
|
|
|
|
|
procedure-arguments
|
|
|
|
|
|
module-commentary))
|
1997-08-18 20:02:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-28 11:56:21 +01:00
|
|
|
|
(define *value-help-handlers*
|
|
|
|
|
|
`(,(lambda (name value)
|
|
|
|
|
|
(object-documentation value))))
|
2009-01-27 13:43:07 +01:00
|
|
|
|
|
|
|
|
|
|
(define (add-value-help-handler! proc)
|
|
|
|
|
|
"Adds a handler for performing `help' on a value.
|
|
|
|
|
|
|
|
|
|
|
|
`proc' will be called as (PROC NAME VALUE). `proc' should return #t to
|
|
|
|
|
|
indicate that it has performed help, a string to override the default
|
|
|
|
|
|
object documentation, or #f to try the other handlers, potentially
|
|
|
|
|
|
falling back on the normal behavior for `help'."
|
|
|
|
|
|
(set! *value-help-handlers* (cons proc *value-help-handlers*)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (remove-value-help-handler! proc)
|
2009-01-28 11:56:21 +01:00
|
|
|
|
"Removes a handler for performing `help' on a value."
|
2009-01-27 13:43:07 +01:00
|
|
|
|
(set! *value-help-handlers* (delete! proc *value-help-handlers*)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (try-value-help name value)
|
|
|
|
|
|
(or-map (lambda (proc) (proc name value)) *value-help-handlers*))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define *name-help-handlers* '())
|
|
|
|
|
|
|
|
|
|
|
|
(define (add-name-help-handler! proc)
|
|
|
|
|
|
"Adds a handler for performing `help' on a name.
|
|
|
|
|
|
|
|
|
|
|
|
`proc' will be called with the unevaluated name as its argument. That is
|
|
|
|
|
|
to say, when the user calls `(help FOO)', the name is FOO, exactly as
|
|
|
|
|
|
the user types it.
|
|
|
|
|
|
|
2009-01-28 11:56:21 +01:00
|
|
|
|
`proc' should return #t to indicate that it has performed help, a string
|
|
|
|
|
|
to override the default object documentation, or #f to try the other
|
|
|
|
|
|
handlers, potentially falling back on the normal behavior for `help'."
|
2009-01-27 13:43:07 +01:00
|
|
|
|
(set! *name-help-handlers* (cons proc *name-help-handlers*)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (remove-name-help-handler! proc)
|
2009-01-28 11:56:21 +01:00
|
|
|
|
"Removes a handler for performing `help' on a name."
|
2009-01-27 13:43:07 +01:00
|
|
|
|
(set! *name-help-handlers* (delete! proc *name-help-handlers*)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (try-name-help name)
|
|
|
|
|
|
(or-map (lambda (proc) (proc name)) *name-help-handlers*))
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-04-13 00:08:22 +00:00
|
|
|
|
;;; Documentation
|
|
|
|
|
|
;;;
|
2008-09-25 17:17:02 +02:00
|
|
|
|
(define-macro (help . exp)
|
|
|
|
|
|
"(help [NAME])
|
2000-04-13 00:08:22 +00:00
|
|
|
|
Prints useful information. Try `(help)'."
|
2008-09-25 17:17:02 +02:00
|
|
|
|
(cond ((not (= (length exp) 1))
|
2008-10-15 22:44:37 +02:00
|
|
|
|
(help-usage)
|
|
|
|
|
|
'(begin))
|
2008-09-25 17:17:02 +02:00
|
|
|
|
((not (provided? 'regex))
|
|
|
|
|
|
(display "`help' depends on the `regex' feature.
|
2008-10-15 22:44:37 +02:00
|
|
|
|
You don't seem to have regular expressions installed.\n")
|
|
|
|
|
|
'(begin))
|
2008-09-25 17:17:02 +02:00
|
|
|
|
(else
|
|
|
|
|
|
(let ((name (car exp))
|
|
|
|
|
|
(not-found (lambda (type x)
|
|
|
|
|
|
(simple-format #t "No ~A found for ~A\n"
|
|
|
|
|
|
type x))))
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
2009-03-17 15:59:40 +01:00
|
|
|
|
;; User-specified
|
|
|
|
|
|
((try-name-help name)
|
|
|
|
|
|
=> (lambda (x) (if (not (eq? x #t)) (display x))))
|
|
|
|
|
|
|
2008-09-25 17:17:02 +02:00
|
|
|
|
;; SYMBOL
|
|
|
|
|
|
((symbol? name)
|
|
|
|
|
|
(help-doc name
|
|
|
|
|
|
(simple-format
|
|
|
|
|
|
#f "^~A$"
|
|
|
|
|
|
(regexp-quote (symbol->string name)))))
|
|
|
|
|
|
|
|
|
|
|
|
;; "STRING"
|
|
|
|
|
|
((string? name)
|
|
|
|
|
|
(help-doc name name))
|
|
|
|
|
|
|
|
|
|
|
|
;; (unquote SYMBOL)
|
|
|
|
|
|
((and (list? name)
|
|
|
|
|
|
(= (length name) 2)
|
|
|
|
|
|
(eq? (car name) 'unquote))
|
2009-03-17 15:59:40 +01:00
|
|
|
|
(let ((doc (try-value-help (cadr name)
|
2009-10-22 22:42:45 +02:00
|
|
|
|
(module-ref (current-module)
|
|
|
|
|
|
(cadr name)))))
|
2009-03-17 15:59:40 +01:00
|
|
|
|
(cond ((not doc) (not-found 'documentation (cadr name)))
|
|
|
|
|
|
((eq? doc #t)) ;; pass
|
|
|
|
|
|
(else (write-line doc)))))
|
2008-09-25 17:17:02 +02:00
|
|
|
|
|
|
|
|
|
|
;; (quote SYMBOL)
|
|
|
|
|
|
((and (list? name)
|
|
|
|
|
|
(= (length name) 2)
|
|
|
|
|
|
(eq? (car name) 'quote)
|
|
|
|
|
|
(symbol? (cadr name)))
|
|
|
|
|
|
(cond ((search-documentation-files (cadr name))
|
|
|
|
|
|
=> write-line)
|
|
|
|
|
|
(else (not-found 'documentation (cadr name)))))
|
|
|
|
|
|
|
|
|
|
|
|
;; (SYM1 SYM2 ...)
|
|
|
|
|
|
((and (list? name)
|
|
|
|
|
|
(and-map symbol? name)
|
|
|
|
|
|
(not (null? name))
|
|
|
|
|
|
(not (eq? (car name) 'quote)))
|
|
|
|
|
|
(cond ((module-commentary name)
|
|
|
|
|
|
=> (lambda (doc)
|
|
|
|
|
|
(display name) (write-line " commentary:")
|
|
|
|
|
|
(write-line doc)))
|
|
|
|
|
|
(else (not-found 'commentary name))))
|
|
|
|
|
|
|
|
|
|
|
|
;; unrecognized
|
2001-05-18 17:05:06 +00:00
|
|
|
|
(else
|
2008-09-25 17:17:02 +02:00
|
|
|
|
(help-usage)))
|
|
|
|
|
|
'(begin)))))
|
2000-04-13 00:08:22 +00:00
|
|
|
|
|
2001-04-28 00:32:23 +00:00
|
|
|
|
(define (module-filename name) ; fixme: better way? / done elsewhere?
|
|
|
|
|
|
(let* ((name (map symbol->string name))
|
|
|
|
|
|
(reverse-name (reverse name))
|
|
|
|
|
|
(leaf (car reverse-name))
|
|
|
|
|
|
(dir-hint-module-name (reverse (cdr reverse-name)))
|
|
|
|
|
|
(dir-hint (apply string-append
|
|
|
|
|
|
(map (lambda (elt)
|
|
|
|
|
|
(string-append elt "/"))
|
|
|
|
|
|
dir-hint-module-name))))
|
|
|
|
|
|
(%search-load-path (in-vicinity dir-hint leaf))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (module-commentary name)
|
|
|
|
|
|
(cond ((module-filename name) => file-commentary)
|
|
|
|
|
|
(else #f)))
|
|
|
|
|
|
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(define (help-doc term regexp)
|
|
|
|
|
|
(let ((entries (apropos-fold (lambda (module name object data)
|
|
|
|
|
|
(cons (list module
|
|
|
|
|
|
name
|
2009-01-28 11:56:21 +01:00
|
|
|
|
(try-value-help name object)
|
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
2009-12-04 19:20:11 +01:00
|
|
|
|
(cond ((procedure? object)
|
2000-09-29 20:39:29 +00:00
|
|
|
|
"a procedure")
|
|
|
|
|
|
(else
|
|
|
|
|
|
"an object")))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
data))
|
|
|
|
|
|
'()
|
|
|
|
|
|
regexp
|
|
|
|
|
|
apropos-fold-exported))
|
|
|
|
|
|
(module car)
|
|
|
|
|
|
(name cadr)
|
2000-09-29 20:39:29 +00:00
|
|
|
|
(doc caddr)
|
|
|
|
|
|
(type cadddr))
|
2001-05-18 17:05:06 +00:00
|
|
|
|
(cond ((not (null? entries))
|
|
|
|
|
|
(let ((first? #t)
|
|
|
|
|
|
(undocumented-entries '())
|
|
|
|
|
|
(documented-entries '())
|
|
|
|
|
|
(documentations '()))
|
|
|
|
|
|
|
|
|
|
|
|
(for-each (lambda (entry)
|
|
|
|
|
|
(let ((entry-summary (simple-format
|
|
|
|
|
|
#f "~S: ~S\n"
|
|
|
|
|
|
(module-name (module entry))
|
|
|
|
|
|
(name entry))))
|
|
|
|
|
|
(if (doc entry)
|
|
|
|
|
|
(begin
|
|
|
|
|
|
(set! documented-entries
|
|
|
|
|
|
(cons entry-summary documented-entries))
|
|
|
|
|
|
;; *fixme*: Use `describe' when we have GOOPS?
|
|
|
|
|
|
(set! documentations
|
|
|
|
|
|
(cons (simple-format
|
|
|
|
|
|
#f "`~S' is ~A in the ~S module.\n\n~A\n"
|
|
|
|
|
|
(name entry)
|
|
|
|
|
|
(type entry)
|
|
|
|
|
|
(module-name (module entry))
|
|
|
|
|
|
(doc entry))
|
|
|
|
|
|
documentations)))
|
|
|
|
|
|
(set! undocumented-entries
|
|
|
|
|
|
(cons entry-summary
|
|
|
|
|
|
undocumented-entries)))))
|
|
|
|
|
|
entries)
|
|
|
|
|
|
|
|
|
|
|
|
(if (and (not (null? documented-entries))
|
|
|
|
|
|
(or (> (length documented-entries) 1)
|
|
|
|
|
|
(not (null? undocumented-entries))))
|
|
|
|
|
|
(begin
|
|
|
|
|
|
(display "Documentation found for:\n")
|
|
|
|
|
|
(for-each (lambda (entry) (display entry))
|
|
|
|
|
|
documented-entries)
|
|
|
|
|
|
(set! first? #f)))
|
|
|
|
|
|
|
|
|
|
|
|
(for-each (lambda (entry)
|
|
|
|
|
|
(if first?
|
|
|
|
|
|
(set! first? #f)
|
|
|
|
|
|
(newline))
|
|
|
|
|
|
(display entry))
|
|
|
|
|
|
documentations)
|
|
|
|
|
|
|
|
|
|
|
|
(if (not (null? undocumented-entries))
|
|
|
|
|
|
(begin
|
|
|
|
|
|
(if first?
|
|
|
|
|
|
(set! first? #f)
|
|
|
|
|
|
(newline))
|
|
|
|
|
|
(display "No documentation found for:\n")
|
|
|
|
|
|
(for-each (lambda (entry) (display entry))
|
|
|
|
|
|
undocumented-entries)))))
|
|
|
|
|
|
((search-documentation-files term)
|
|
|
|
|
|
=> (lambda (doc)
|
|
|
|
|
|
(write-line "Documentation from file:")
|
|
|
|
|
|
(write-line doc)))
|
|
|
|
|
|
(else
|
|
|
|
|
|
;; no matches
|
|
|
|
|
|
(display "Did not find any object ")
|
|
|
|
|
|
(simple-format #t
|
|
|
|
|
|
(if (symbol? term)
|
|
|
|
|
|
"named `~A'\n"
|
|
|
|
|
|
"matching regexp \"~A\"\n")
|
|
|
|
|
|
term)))))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
|
2000-04-13 00:08:22 +00:00
|
|
|
|
(define (help-usage)
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(display "Usage: (help NAME) gives documentation about objects named NAME (a symbol)
|
|
|
|
|
|
(help REGEXP) ditto for objects with names matching REGEXP (a string)
|
2001-05-18 17:10:42 +00:00
|
|
|
|
(help 'NAME) gives documentation for NAME, even if it is not an object
|
2000-06-11 19:18:22 +00:00
|
|
|
|
(help ,EXPR) gives documentation for object returned by EXPR
|
2001-04-28 00:35:02 +00:00
|
|
|
|
(help (my module)) gives module commentary for `(my module)'
|
2000-04-13 00:08:22 +00:00
|
|
|
|
(help) gives this text
|
|
|
|
|
|
|
2000-06-11 18:31:10 +00:00
|
|
|
|
`help' searches among bindings exported from loaded modules, while
|
|
|
|
|
|
`apropos' searches among bindings visible from the \"current\" module.
|
|
|
|
|
|
|
2000-04-13 00:15:21 +00:00
|
|
|
|
Examples: (help help)
|
|
|
|
|
|
(help cons)
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(help \"output-string\")
|
2000-04-13 00:08:22 +00:00
|
|
|
|
|
|
|
|
|
|
Other useful sources of helpful information:
|
|
|
|
|
|
|
|
|
|
|
|
(apropos STRING)
|
|
|
|
|
|
(arity PROCEDURE)
|
|
|
|
|
|
(name PROCEDURE-OR-MACRO)
|
|
|
|
|
|
(source PROCEDURE-OR-MACRO)
|
|
|
|
|
|
|
|
|
|
|
|
Tools:
|
|
|
|
|
|
|
2000-04-13 00:15:21 +00:00
|
|
|
|
(backtrace) ;show backtrace from last error
|
|
|
|
|
|
(debug) ;enter the debugger
|
|
|
|
|
|
(trace [PROCEDURE]) ;trace procedure (no arg => show)
|
|
|
|
|
|
(untrace [PROCEDURE]) ;untrace (no arg => untrace all)
|
2000-04-13 00:08:22 +00:00
|
|
|
|
|
|
|
|
|
|
(OPTIONSET-options 'full) ;display option information
|
|
|
|
|
|
(OPTIONSET-enable 'OPTION)
|
|
|
|
|
|
(OPTIONSET-disable 'OPTION)
|
|
|
|
|
|
(OPTIONSET-set! OPTION VALUE)
|
|
|
|
|
|
|
|
|
|
|
|
where OPTIONSET is one of debug, read, eval, print
|
|
|
|
|
|
|
|
|
|
|
|
"))
|
|
|
|
|
|
|
1997-08-18 20:02:22 +00:00
|
|
|
|
;;; {Apropos}
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; Author: Roland Orre <orre@nada.kth.se>
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
2011-12-12 23:42:04 +01:00
|
|
|
|
;; Two arguments: the module, and the pattern, as a string.
|
|
|
|
|
|
;;
|
|
|
|
|
|
(define apropos-hook (make-hook 2))
|
|
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (apropos rgx . options)
|
1997-08-18 20:02:22 +00:00
|
|
|
|
"Search for bindings: apropos regexp {options= 'full 'shadow 'value}"
|
2011-12-12 23:42:04 +01:00
|
|
|
|
(run-hook apropos-hook (current-module) rgx)
|
1997-08-18 20:02:22 +00:00
|
|
|
|
(if (zero? (string-length rgx))
|
|
|
|
|
|
"Empty string not allowed"
|
1997-08-18 20:19:18 +00:00
|
|
|
|
(let* ((match (make-regexp rgx))
|
2003-03-13 10:16:30 +00:00
|
|
|
|
(uses (module-uses (current-module)))
|
1997-08-18 20:02:22 +00:00
|
|
|
|
(modules (cons (current-module)
|
2003-03-13 10:16:30 +00:00
|
|
|
|
(if (and (not (null? uses))
|
|
|
|
|
|
(eq? (module-name (car uses))
|
|
|
|
|
|
'duplicates))
|
|
|
|
|
|
(cdr uses)
|
|
|
|
|
|
uses)))
|
1997-08-18 20:02:22 +00:00
|
|
|
|
(separator #\tab)
|
|
|
|
|
|
(shadow (member 'shadow options))
|
|
|
|
|
|
(value (member 'value options)))
|
|
|
|
|
|
(cond ((member 'full options)
|
|
|
|
|
|
(set! shadow #t)
|
|
|
|
|
|
(set! value #t)))
|
|
|
|
|
|
(for-each
|
|
|
|
|
|
(lambda (module)
|
2001-05-15 14:59:42 +00:00
|
|
|
|
(let* ((name (module-name module))
|
|
|
|
|
|
(obarray (module-obarray module)))
|
|
|
|
|
|
;; XXX - should use hash-fold here
|
2003-03-04 11:56:10 +00:00
|
|
|
|
(hash-for-each
|
|
|
|
|
|
(lambda (symbol variable)
|
|
|
|
|
|
(cond ((regexp-exec match (symbol->string symbol))
|
|
|
|
|
|
(display name)
|
|
|
|
|
|
(display ": ")
|
|
|
|
|
|
(display symbol)
|
|
|
|
|
|
(cond ((variable-bound? variable)
|
|
|
|
|
|
(let ((val (variable-ref variable)))
|
|
|
|
|
|
(cond ((or (procedure? val) value)
|
|
|
|
|
|
(display separator)
|
|
|
|
|
|
(display val)))))
|
|
|
|
|
|
(else
|
|
|
|
|
|
(display separator)
|
|
|
|
|
|
(display "(unbound)")))
|
|
|
|
|
|
(if (and shadow
|
|
|
|
|
|
(not (eq? (module-ref module symbol)
|
|
|
|
|
|
(module-ref (current-module) symbol))))
|
|
|
|
|
|
(display " shadowed"))
|
|
|
|
|
|
(newline))))
|
2000-12-13 09:44:28 +00:00
|
|
|
|
obarray)))
|
1997-08-18 20:02:22 +00:00
|
|
|
|
modules))))
|
1997-08-24 03:39:47 +00:00
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (apropos-internal rgx)
|
1997-08-24 03:39:47 +00:00
|
|
|
|
"Return a list of accessible variable names."
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(apropos-fold (lambda (module name var data)
|
|
|
|
|
|
(cons name data))
|
|
|
|
|
|
'()
|
|
|
|
|
|
rgx
|
|
|
|
|
|
(apropos-fold-accessible (current-module))))
|
|
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (apropos-fold proc init rgx folder)
|
2000-06-11 18:31:10 +00:00
|
|
|
|
"Folds PROCEDURE over bindings matching third arg REGEXP.
|
|
|
|
|
|
|
|
|
|
|
|
Result is
|
|
|
|
|
|
|
|
|
|
|
|
(PROCEDURE MODULE1 NAME1 VALUE1
|
|
|
|
|
|
(PROCEDURE MODULE2 NAME2 VALUE2
|
|
|
|
|
|
...
|
|
|
|
|
|
(PROCEDURE MODULEn NAMEn VALUEn INIT)))
|
|
|
|
|
|
|
|
|
|
|
|
where INIT is the second arg to `apropos-fold'.
|
|
|
|
|
|
|
|
|
|
|
|
Fourth arg FOLDER is one of
|
|
|
|
|
|
|
|
|
|
|
|
(apropos-fold-accessible MODULE) ;fold over bindings accessible in MODULE
|
|
|
|
|
|
apropos-fold-exported ;fold over all exported bindings
|
|
|
|
|
|
apropos-fold-all ;fold over all bindings"
|
2011-12-12 23:42:04 +01:00
|
|
|
|
(run-hook apropos-hook (current-module) rgx)
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(let ((match (make-regexp rgx))
|
2011-01-07 22:01:27 -08:00
|
|
|
|
(recorded (make-hash-table)))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(let ((fold-module
|
|
|
|
|
|
(lambda (module data)
|
|
|
|
|
|
(let* ((obarray-filter
|
|
|
|
|
|
(lambda (name val data)
|
2000-10-10 07:32:45 +00:00
|
|
|
|
(if (and (regexp-exec match (symbol->string name))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(not (hashq-get-handle recorded name)))
|
|
|
|
|
|
(begin
|
|
|
|
|
|
(hashq-set! recorded name #t)
|
|
|
|
|
|
(proc module name val data))
|
|
|
|
|
|
data)))
|
|
|
|
|
|
(module-filter
|
|
|
|
|
|
(lambda (name var data)
|
2001-06-02 18:32:03 +00:00
|
|
|
|
(if (variable-bound? var)
|
|
|
|
|
|
(obarray-filter name (variable-ref var) data)
|
|
|
|
|
|
data))))
|
2001-05-15 14:59:42 +00:00
|
|
|
|
(cond (module (hash-fold module-filter
|
2000-06-11 18:31:10 +00:00
|
|
|
|
data
|
|
|
|
|
|
(module-obarray module)))
|
|
|
|
|
|
(else data))))))
|
|
|
|
|
|
(folder fold-module init))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (make-fold-modules init-thunk traverse extract)
|
|
|
|
|
|
"Return procedure capable of traversing a forest of modules.
|
|
|
|
|
|
The forest traversed is the image of the forest generated by root
|
|
|
|
|
|
modules returned by INIT-THUNK and the generator TRAVERSE.
|
|
|
|
|
|
It is an image under the mapping EXTRACT."
|
|
|
|
|
|
(lambda (fold-module init)
|
2000-06-20 17:10:34 +00:00
|
|
|
|
(let* ((table (make-hash-table 31))
|
|
|
|
|
|
(first? (lambda (obj)
|
2000-06-20 17:15:21 +00:00
|
|
|
|
(let* ((handle (hash-create-handle! table obj #t))
|
|
|
|
|
|
(first? (cdr handle)))
|
|
|
|
|
|
(set-cdr! handle #f)
|
|
|
|
|
|
first?))))
|
2000-06-20 17:10:34 +00:00
|
|
|
|
(let rec ((data init)
|
|
|
|
|
|
(modules (init-thunk)))
|
|
|
|
|
|
(do ((modules modules (cdr modules))
|
|
|
|
|
|
(data data (if (first? (car modules))
|
|
|
|
|
|
(rec (fold-module (extract (car modules)) data)
|
|
|
|
|
|
(traverse (car modules)))
|
|
|
|
|
|
data)))
|
|
|
|
|
|
((null? modules) data))))))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (apropos-fold-accessible module)
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(make-fold-modules (lambda () (list module))
|
|
|
|
|
|
module-uses
|
2001-05-18 17:05:06 +00:00
|
|
|
|
identity))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
|
|
|
|
|
|
(define (root-modules)
|
2010-04-23 16:07:14 +02:00
|
|
|
|
(submodules (resolve-module '() #f)))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
|
2010-08-31 14:13:43 +02:00
|
|
|
|
(define (submodules mod)
|
|
|
|
|
|
(hash-map->list (lambda (k v) v) (module-submodules mod)))
|
2000-06-11 18:31:10 +00:00
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define apropos-fold-exported
|
2000-06-11 18:31:10 +00:00
|
|
|
|
(make-fold-modules root-modules submodules module-public-interface))
|
|
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define apropos-fold-all
|
2001-05-18 17:05:06 +00:00
|
|
|
|
(make-fold-modules root-modules submodules identity))
|
1997-09-11 08:59:30 +00:00
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (source obj)
|
1997-09-11 08:59:30 +00:00
|
|
|
|
(cond ((procedure? obj) (procedure-source obj))
|
|
|
|
|
|
((macro? obj) (procedure-source (macro-transformer obj)))
|
|
|
|
|
|
(else #f)))
|
1998-11-26 18:04:46 +00:00
|
|
|
|
|
* lib.scm: Move module the system directives `export',
`export-syntax', `re-export' and `re-export-syntax' into the
`define-module' form. This is the recommended way of exporting
bindings.
* srfi-2.scm, srfi-4.scm, srfi-8.scm, srfi-9.scm, srfi-10.scm,
srfi-11.scm, srfi-14.scm, srfi-16.scm: Move module the system
directives `export', `export-syntax', `re-export' and
`re-export-syntax' into the `define-module' form. This is the
recommended way of exporting bindings.
* goops.scm, goops/active-slot.scm, goops/compile.scm,
goops/composite-slot.scm, goops/describe.scm, goops/dispatch.scm,
goops/old-define-method.scm, goops/save.scm, goops/util.scm: Move
module the system directives `export', `export-syntax',
`re-export' and `re-export-syntax' into the `define-module' form.
This is the recommended way of exporting bindings.
* slib.scm (array-indexes): New procedure.
(*features*): Extend. (Probably some of these options should be
set elsewhere.) (Thanks to Aubrey Jaffer.)
* and-let-star-compat.scm, and-let-star.scm, calling.scm,
channel.scm, common-list.scm, debug.scm, debugger.scm,
expect.scm, hcons.scm, lineio.scm, ls.scm, mapping.scm,
null.scm, optargs.scm, poe.scm, popen.scm, pretty-print.scm,
q.scm, r5rs.scm, rdelim.scm, regex.scm, runq.scm, safe-r5rs.scm,
safe.scm, session.scm, slib.scm, streams.scm, string-fun.scm,
syncase.scm, threads.scm: Move module the system directives
`export', `export-syntax', `re-export' and `re-export-syntax'
into the `define-module' form. This is the recommended way of
exporting bindings.
2001-10-21 09:49:19 +00:00
|
|
|
|
(define (arity obj)
|
2001-09-09 01:00:30 +00:00
|
|
|
|
(define (display-arg-list arg-list)
|
|
|
|
|
|
(display #\`)
|
|
|
|
|
|
(display (car arg-list))
|
|
|
|
|
|
(let loop ((ls (cdr arg-list)))
|
|
|
|
|
|
(cond ((null? ls)
|
|
|
|
|
|
(display #\'))
|
|
|
|
|
|
((not (pair? ls))
|
|
|
|
|
|
(display "', the rest in `")
|
|
|
|
|
|
(display ls)
|
|
|
|
|
|
(display #\'))
|
|
|
|
|
|
(else
|
|
|
|
|
|
(if (pair? (cdr ls))
|
|
|
|
|
|
(display "', `")
|
|
|
|
|
|
(display "' and `"))
|
|
|
|
|
|
(display (car ls))
|
|
|
|
|
|
(loop (cdr ls))))))
|
|
|
|
|
|
(define (display-arg-list/summary arg-list type)
|
|
|
|
|
|
(let ((len (length arg-list)))
|
|
|
|
|
|
(display len)
|
|
|
|
|
|
(display " ")
|
|
|
|
|
|
(display type)
|
|
|
|
|
|
(if (> len 1)
|
|
|
|
|
|
(display " arguments: ")
|
|
|
|
|
|
(display " argument: "))
|
|
|
|
|
|
(display-arg-list arg-list)))
|
|
|
|
|
|
(cond
|
|
|
|
|
|
((procedure-property obj 'arglist)
|
|
|
|
|
|
=> (lambda (arglist)
|
|
|
|
|
|
(let ((required-args (car arglist))
|
|
|
|
|
|
(optional-args (cadr arglist))
|
|
|
|
|
|
(keyword-args (caddr arglist))
|
|
|
|
|
|
(allow-other-keys? (cadddr arglist))
|
|
|
|
|
|
(rest-arg (car (cddddr arglist)))
|
|
|
|
|
|
(need-punctuation #f))
|
|
|
|
|
|
(cond ((not (null? required-args))
|
|
|
|
|
|
(display-arg-list/summary required-args "required")
|
|
|
|
|
|
(set! need-punctuation #t)))
|
|
|
|
|
|
(cond ((not (null? optional-args))
|
|
|
|
|
|
(if need-punctuation (display ", "))
|
|
|
|
|
|
(display-arg-list/summary optional-args "optional")
|
|
|
|
|
|
(set! need-punctuation #t)))
|
|
|
|
|
|
(cond ((not (null? keyword-args))
|
|
|
|
|
|
(if need-punctuation (display ", "))
|
|
|
|
|
|
(display-arg-list/summary keyword-args "keyword")
|
|
|
|
|
|
(set! need-punctuation #t)))
|
|
|
|
|
|
(cond (allow-other-keys?
|
|
|
|
|
|
(if need-punctuation (display ", "))
|
|
|
|
|
|
(display "other keywords allowed")
|
|
|
|
|
|
(set! need-punctuation #t)))
|
|
|
|
|
|
(cond (rest-arg
|
|
|
|
|
|
(if need-punctuation (display ", "))
|
|
|
|
|
|
(display "the rest in `")
|
|
|
|
|
|
(display rest-arg)
|
|
|
|
|
|
(display "'"))))))
|
|
|
|
|
|
(else
|
2010-04-17 16:28:52 +02:00
|
|
|
|
(let ((arity (procedure-minimum-arity obj)))
|
2001-09-09 01:00:30 +00:00
|
|
|
|
(display (car arity))
|
|
|
|
|
|
(cond ((caddr arity)
|
|
|
|
|
|
(display " or more"))
|
|
|
|
|
|
((not (zero? (cadr arity)))
|
|
|
|
|
|
(display " required and ")
|
|
|
|
|
|
(display (cadr arity))
|
|
|
|
|
|
(display " optional")))
|
|
|
|
|
|
(if (and (not (caddr arity))
|
|
|
|
|
|
(= (car arity) 1)
|
|
|
|
|
|
(<= (cadr arity) 1))
|
|
|
|
|
|
(display " argument")
|
eval.c closures are now applicable smobs, not tc3s
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
2009-12-04 19:20:11 +01:00
|
|
|
|
(display " arguments")))))
|
2001-09-09 01:00:30 +00:00
|
|
|
|
(display ".\n"))
|
1999-03-19 02:15:43 +00:00
|
|
|
|
|
2009-02-25 00:06:58 +01:00
|
|
|
|
|
|
|
|
|
|
(define (procedure-arguments proc)
|
|
|
|
|
|
"Return an alist describing the arguments that `proc' accepts, or `#f'
|
|
|
|
|
|
if the information cannot be obtained.
|
|
|
|
|
|
|
|
|
|
|
|
The alist keys that are currently defined are `required', `optional',
|
2012-07-01 17:32:03 +02:00
|
|
|
|
`keyword', `allow-other-keys?', and `rest'."
|
2009-02-25 00:06:58 +01:00
|
|
|
|
(cond
|
|
|
|
|
|
((procedure-property proc 'arglist)
|
2012-07-01 17:32:03 +02:00
|
|
|
|
=> (match-lambda
|
|
|
|
|
|
((req opt keyword aok? rest)
|
2012-07-06 12:19:12 +02:00
|
|
|
|
`((required . ,(if (number? req)
|
|
|
|
|
|
(make-list req '_)
|
|
|
|
|
|
req))
|
|
|
|
|
|
(optional . ,(if (number? opt)
|
|
|
|
|
|
(make-list opt '_)
|
|
|
|
|
|
opt))
|
2012-07-01 17:32:03 +02:00
|
|
|
|
(keyword . ,keyword)
|
|
|
|
|
|
(allow-other-keys? . ,aok?)
|
|
|
|
|
|
(rest . ,rest)))))
|
2009-02-25 00:06:58 +01:00
|
|
|
|
((procedure-source proc)
|
|
|
|
|
|
=> cadr)
|
2013-11-19 19:11:40 +01:00
|
|
|
|
(((@ (system vm program) program?) proc)
|
2010-01-12 22:50:10 +01:00
|
|
|
|
((@ (system vm program) program-arguments-alist) proc))
|
2009-02-25 00:06:58 +01:00
|
|
|
|
(else #f)))
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-18 17:05:06 +00:00
|
|
|
|
;;; session.scm ends here
|