From 9a44c262d2ff8fb625ca0dafda57d4902a4d9c50 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 19 May 2008 12:26:20 +0200 Subject: [PATCH] add compile-toplevel and evaluate conditions to eval-case * ice-9/boot-9.scm (eval-case): Define two more conditions: compile-toplevel and evaluate, as common lisp and chez scheme do. (defmacro, define-option-interface, define-macro, define-syntax-macro) (define-module, use-modules, use-syntax, define-public) (defmacro-public, export, re-export): Add `compile-toplevel' to all uses of eval-case. --- ice-9/boot-9.scm | 32 +++++++++++++++++--------------- 1 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index c8b9ab6..f6fd6fb 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -92,9 +92,11 @@ ;; (eval-case ((situation*) forms)* (else forms)?) ;; ;; Evaluate certain code based on the situation that eval-case is used -;; in. The only defined situation right now is `load-toplevel' which -;; triggers for code evaluated at the top-level, for example from the -;; REPL or when loading a file. +;; in. There are three situations defined. `load-toplevel' triggers for +;; code evaluated at the top-level, for example from the REPL or when +;; loading a file. `compile-toplevel' triggers for code compiled at the +;; toplevel. `execute' triggers during execution of code not at the top +;; level. (define eval-case (procedure->memoizing-macro @@ -151,7 +153,7 @@ (lambda (name parms . body) (let ((transformer `(lambda ,parms ,@body))) `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (define ,name (defmacro:transformer ,transformer))) (else (error "defmacro can only be used at the top level"))))))) @@ -2257,8 +2259,8 @@ (define ,(caddr options/enable/disable) ,(make-disable interface)) (defmacro ,(caaddr option-group) (opt val) - `(,,(car options/enable/disable) - (append (,,(car options/enable/disable)) + `(,',(car options/enable/disable) + (append (,',(car options/enable/disable)) (list ',opt ,val)))))))))) (define-option-interface @@ -2699,7 +2701,7 @@ (car rest) `(lambda ,(cdr first) ,@rest)))) `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (define ,name (defmacro:transformer ,transformer))) (else (error "define-macro can only be used at the top level"))))) @@ -2712,7 +2714,7 @@ (car rest) `(lambda ,(cdr first) ,@rest)))) `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (define ,name (defmacro:syntax-transformer ,transformer))) (else (error "define-syntax-macro can only be used at the top level"))))) @@ -2827,7 +2829,7 @@ (defmacro define-module args `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (let ((m (process-define-module (list ,@(compile-define-module-args args))))) (set-current-module m) @@ -2852,7 +2854,7 @@ (defmacro use-modules modules `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (process-use-modules (list ,@(map (lambda (m) `(list ,@(compile-interface-spec m))) @@ -2863,7 +2865,7 @@ (defmacro use-syntax (spec) `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) ,@(if (pair? spec) `((process-use-modules (list (list ,@(compile-interface-spec spec)))) @@ -2893,7 +2895,7 @@ (let ((name (defined-name (car args)))) `(begin (define-private ,@args) - (eval-case ((load-toplevel) (export ,name)))))))) + (eval-case ((load-toplevel compile-toplevel) (export ,name)))))))) (defmacro defmacro-public args (define (syntax) @@ -2908,7 +2910,7 @@ (#t (let ((name (defined-name (car args)))) `(begin - (eval-case ((load-toplevel) (export-syntax ,name))) + (eval-case ((load-toplevel compile-toplevel) (export-syntax ,name))) (defmacro ,@args)))))) ;; Export a local variable @@ -2947,7 +2949,7 @@ (defmacro export names `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (call-with-deferred-observers (lambda () (module-export! (current-module) ',names)))) @@ -2956,7 +2958,7 @@ (defmacro re-export names `(eval-case - ((load-toplevel) + ((load-toplevel compile-toplevel) (call-with-deferred-observers (lambda () (module-re-export! (current-module) ',names)))) -- 1.5.5-rc2.GIT