From: David Vazquez Date: Sat, 19 Jan 2013 12:58:22 +0000 (+0000) Subject: Global special declaration X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=cfaa37082d44f5e34c7a92623320a30096fb063b;p=jscl.git Global special declaration Change defvar definition to include it --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 8cb2b9f..12ee19d 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -40,7 +40,7 @@ `(eval-when-compile ,@(mapcar (lambda (decl) `(!proclaim ',decl)) decls))) - (declaim (constant nil t)) + (declaim (constant nil t) (special t nil)) (setq nil 'nil) (setq t 't) @@ -52,6 +52,7 @@ (defmacro defvar (name value &optional docstring) `(progn + (declaim (special ,name)) (unless (boundp ',name) (setq ,name ,value)) ,@(when (stringp docstring) `((oset ',name "vardoc" ,docstring))) ',name)) @@ -1000,6 +1001,10 @@ (defun !proclaim (decl) (case (car decl) + (special + (dolist (name (cdr decl)) + (let ((b (global-binding name 'variable 'variable))) + (push-binding-declaration 'special b)))) (notinline (dolist (name (cdr decl)) (let ((b (global-binding name 'function 'function))) @@ -1255,11 +1260,13 @@ (let ((variables (mapcar #'first bindings)) (values (mapcar #'second bindings))) (let ((cvalues (mapcar #'ls-compile values)) - (*environment* (extend-local-env (remove-if #'boundp variables))) + (*environment* + (extend-local-env (remove-if (lambda (v)(claimp v 'variable 'special)) + variables))) (dynamic-bindings)) (concat "(function(" (join (mapcar (lambda (x) - (if (boundp x) + (if (claimp x 'variable 'special) (let ((v (gvarname x))) (push (cons x v) dynamic-bindings) v)