#| -*-Scheme-*-
-$Id: global.scm,v 14.68 2004/10/01 02:47:51 cph Exp $
+$Id: global.scm,v 14.69 2004/10/30 03:56:14 cph Exp $
Copyright 1988,1989,1991,1992,1993,1995 Massachusetts Institute of Technology
Copyright 1998,2000,2001,2003,2004 Massachusetts Institute of Technology
(with-output-to-truncated-string max (lambda () (write object)))))
\f
(define (pa procedure)
- (cond ((not (procedure? procedure))
- (error "Must be a procedure" procedure))
- ((procedure-lambda procedure)
+ (guarantee-procedure procedure 'PA)
+ (cond ((procedure-lambda procedure)
=> (lambda (scode)
(pp (unsyntax-lambda-list scode))))
((and (primitive-procedure? procedure)
(lambda ()
(write-string " -- done" port)
(newline port))))
- (do-it no-print no-print))))
\ No newline at end of file
+ (do-it no-print no-print))))
+\f
+;;;; Hook lists
+
+(define-record-type <hook-list>
+ (%make-hook-list hooks)
+ hook-list?
+ (hooks hook-list-hooks set-hook-list-hooks!))
+
+(define (make-hook-list)
+ (%make-hook-list '()))
+
+(define (guarantee-hook-list object caller)
+ (if (not (hook-list? object))
+ (error:not-hook-list object caller)))
+
+(define (error:not-hook-list object caller)
+ (error:wrong-type-argument object "hook list" caller))
+
+(define (append-hook-to-list hook-list key hook)
+ (guarantee-hook-list hook-list 'APPEND-HOOK-TO-LIST)
+ (let loop ((alist (hook-list-hooks hook-list)) (prev #f))
+ (if (pair? alist)
+ (loop (cdr alist)
+ (if (eq? (caar alist) key)
+ (begin
+ (if prev
+ (set-cdr! prev (cdr alist))
+ (set-hook-list-hooks! hook-list (cdr alist)))
+ prev)
+ alist))
+ (let ((tail (list (cons key hook))))
+ (if prev
+ (set-cdr! prev tail)
+ (set-hook-list-hooks! hook-list tail))))))
+
+(define (remove-hook-from-list hook-list key)
+ (guarantee-hook-list hook-list 'REMOVE-HOOK-FROM-LIST)
+ (let loop ((alist (hook-list-hooks hook-list)) (prev #f))
+ (if (pair? alist)
+ (loop (cdr alist)
+ (if (eq? (caar alist) key)
+ (begin
+ (if prev
+ (set-cdr! prev (cdr alist))
+ (set-hook-list-hooks! hook-list (cdr alist)))
+ prev)
+ alist)))))
+
+(define (run-hooks-in-list hook-list . arguments)
+ (guarantee-hook-list hook-list 'RUN-HOOKS-IN-LIST)
+ (for-each (lambda (p)
+ (apply (cdr p) arguments))
+ (hook-list-hooks hook-list)))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.504 2004/10/28 22:53:20 cph Exp $
+$Id: runtime.pkg,v 14.505 2004/10/30 03:56:39 cph Exp $
Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology
Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology
%exit
%quit
*the-non-printing-object*
+ <hook-list>
+ append-hook-to-list
apply
bind-cell-contents!
call-with-values
environment-link-name
eq?
error-procedure
+ error:not-hook-list
eval
exit
false-procedure
fasdump
get-fixed-objects-vector
get-interrupt-enables
+ guarantee-hook-list
+ hook-list?
hook/exit
hook/quit
hook/scode-eval
link-variables
local-assignment
make-cell
+ make-hook-list
make-non-pointer-object
non-pointer-type-code?
null-procedure
primitive-procedure-documentation
pwd
quit
+ remove-hook-from-list
+ run-hooks-in-list
scode-eval
set-cell-contents!
set-interrupt-enables!