[gambit-list] Parameter objects performance Q

Lassi Kortela lassi at lassi.io
Mon Mar 9 04:51:55 EDT 2020

> For completeness, I asked a Common Lisper about CL dynamic variables. 
> Here is how CL dynamic variables work:

All correct.

In addition to defvar and defparameter (which are almost synonymous) you 
can also make ad-hoc dynamic variables with (declare (special my-var)):

(defun special-test ()
   (labels ((print-value-of-foo ()
              (declare (special foo))
              (print foo)))
     (let ((foo 123))
       (declare (special foo))

(defvar a nil)

(defun special-test-2 ()
   (labels ((print-value-of-a ()
              (print a)
              ;; These would not work since b and c are lexical:
              ;;(print b)
              ;;(print c)
     (multiple-value-bind (a b c) (values 1 2 3)


CL also has a standard concept of dynamic extent (dynamic scope is for 
bindings; dynamic extent is for values), as well as a declaration to go 
with it: 

E.g. with-open-file 
"The stream object to which the stream variable is bound has dynamic 
extent; its extent ends when the form is exited."

More information about the Gambit-list mailing list