Changeset 11622


Ignore:
Timestamp:
Jan 17, 2009, 10:00:52 AM (11 years ago)
Author:
gb
Message:

Invent DEFSTATICVAR, which is to DEFSTATIC as DEFVAR is to
DEFPARAMETER. Use it in the expansion of DEFLOADVAR, to avoid
problems with reinitialization when a DEFLOADVAR is executed twice
in the same session.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/macros.lisp

    r11590 r11622  
    735735     (%defglobal ',var ,value ,doc)))
    736736
     737(defmacro defstaticvar (&environment env var value &optional doc)
     738  "Syntax is like DEFVAR.  Proclaims the symbol to be special,
     739but also asserts that it will never be given a per-thread dynamic
     740binding.  The value of the variable can be changed (via SETQ, etc.),
     741but since all threads access the same static binding of the variable,
     742such changes should be made with care.  Like DEFVAR, the initial value
     743form is not evaluated if the variable is already BOUNDP."
     744  (if (and doc (not (stringp doc))) (signal-program-error "~S is not a string." doc))
     745  (if (and (compile-file-environment-p env) (not *fasl-save-doc-strings*))
     746    (setq doc nil))
     747  `(progn
     748     (eval-when (:compile-toplevel)
     749       (note-variable-info ',var :global ,env))
     750     (%defvar-init ,var ,value ,doc)))
     751
    737752
    738753(defmacro defglobal (&rest args)
     
    743758(defmacro defloadvar (&environment env var value &optional doc)
    744759  `(progn
    745      (defstatic ,var ,nil ,@(if doc `(,doc)))
     760     (defstaticvar ,var ,nil ,@(if doc `(,doc)))
    746761     (def-ccl-pointers ,var ()
    747762       (setq ,var ,value))
Note: See TracChangeset for help on using the changeset viewer.