<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">For completeness, I asked a Common Lisper about CL dynamic variables. Here is how CL dynamic variables work:</div><div dir="ltr"><br></div><div dir="ltr"> * In CL, all global variables are "dynamic", and they're defined using |defvar|.</div><div dir="ltr"><br></div><div dir="ltr"> * By convention their names are prefixed and suffixed by stars, which is not required by the language.</div><div dir="ltr"><br></div><div dir="ltr"> * In the place of Scheme |parameterize|, CL uses ordinary |let|.</div><div dir="ltr"><br></div><div dir="ltr">   I.e., CL |let| when binding the name of a global variable means |parameterize|, and otherwise means |let|.</div><div dir="ltr"><br></div><div dir="ltr"> * In the place of the procedure call as accessor ("(myparam)"), CL uses normal variable load ("myparam").</div><div dir="ltr"><br></div><div dir="ltr"> * I wildguess a condition that makes it easier for CL to accommodate this syntax without incredible overhead, is the fact that they do not have first class continuations (but only escape continuations which mean N-step procedure return), so they don't have the question "which dynamic variable assignment should apply in which continuation".</div><div dir="ltr"><br></div><div dir="ltr">   He also confirmed that in CL, |let| of a dynamic variable, *implies backup of the variable's previous value, and at return time, restore of the variable to that previous value*. This restore is carried out also in case of "abnormal termination", example: (tagbody (let ((*v* 234)) (go a)) a) or (tagbody (let ((*v* 234)) (print "hello") (go a) (print "hi")) a), go means non-local control transfer (goto).<br></div><div dir="ltr"><br></div><div dir="ltr"><br>Example 1, prints out "123":</div><div dir="ltr">(defvar *v*) ; <- Define dynamic variable ()<br>(defun a ()<br>  (let ((*v* 123)) ; <- Note, let on a dynamic variable means |parameterize|<br>    (b)))<br>(defun b () (c))<br>(defun c () (print *v*)) ; <- Use, same syntax as normal variable access.</div><div dir="ltr"><br></div><div dir="ltr"><br>Example 2, prints out "123234":</div><div dir="ltr">(defvar *v*) ; <- Define dynamic variable ()<br>(defun a ()<br>  (let ((*v* 123)) ; <- Note, let on a dynamic variable means |parameterize|<br>    (d)<br>    (b)))<br>(defun b ()<br>  (let ((*v* 234))<br>    (c)))<br>(defun c () (d))<br>(defun d () (print *v*)) ; <- Use, same syntax as normal variable access.</div><div dir="ltr"><br></div><div dir="ltr"><br>Reference is the "Common Lisp HyperSpec" produced by LispWorks:<br><a href="http://www.lispworks.com/reference/HyperSpec/Body/03_abaab.htm">http://www.lispworks.com/reference/HyperSpec/Body/03_abaab.htm</a></div><div dir="ltr"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
</blockquote></div></div>
</blockquote></div></div></div></div>
</blockquote></div></div></div></div></div>