set.scm 702 B

123456789101112131415161718192021
  1. (define-module (lang elisp internals set)
  2. #:use-module (lang elisp internals evaluation)
  3. #:use-module (lang elisp internals signal)
  4. #:export (set value))
  5. ;; Set SYM's variable value to VAL, and return VAL.
  6. (define (set sym val)
  7. (if (module-defined? the-elisp-module sym)
  8. (module-set! the-elisp-module sym val)
  9. (module-define! the-elisp-module sym val))
  10. val)
  11. ;; Return SYM's variable value. If it has none, signal an error if
  12. ;; MUST-EXIST is true, just return #nil otherwise.
  13. (define (value sym must-exist)
  14. (if (module-defined? the-elisp-module sym)
  15. (module-ref the-elisp-module sym)
  16. (if must-exist
  17. (error "Symbol's value as variable is void:" sym)
  18. %nil)))