From: Nikodemus S. <tsi...@cc...> - 2004-04-20 15:23:17
|
On Tue, 20 Apr 2004, Christophe Rhodes wrote: > So, firstly, is this over-speculative generality, or is my analysis of > the need correct? (How do other Lisps overcome compile-time package > lock checking locally, if indeed they do?) As far as I can tell, they don't. Both CMUCL and Allegro use WITHOUT-PACKAGE-LOCKS, which expands into: (let ((*enable-package-locks* nil)) ...) I really like the declaration protocol, but I just started thinking: is this really a half-way house? As you hint, it would be good for users to be able make meaningfull declarations in for use in their own compile-time protocols, and it might make more sense to provide documented environment then shoehorn everything into restarts. Then users could do: (define-compiler-macro bar (&whole form &env env x) (if (subtypep (variable-type x env) '(integer 0 0)) 1.0 (let ((decl (cdr (assoc 'unoptimizable-bar (declarations env))))) (if (and (consp decl) (eq 'use-random (car decl))) `(random ,(cdr decl)) form)))) (defun foo (x) (declare (unoptimizable-bar (use-random 1.0)) (bar x)) For package locks the protocol would become eg: (in-package "Foo") (defmacro foo () ...) (defun make-macrolet (&body body) `(locally (declare (disable-package-locks "Foo")) (macrolet ((foo () ...)) (declare (enable-package-locks "Foo")) ,@body))) I haven't really thought this option through yet, esp. not the way it will interact with the in-severe-need-of-more-specification compile vs. runtimeness of package locks. Cheers, -- Nikodemus |