Write a lisp function named test-scoping to investigate the scoping rules of lisp, with respect to local variables created by let (my experiments suggest that things are a bit different with respect to global variables). Your function should return the string "dynamic" if the lisp system running the function uses dynamic scoping and "static" if it uses static scoping.
You may use at most one "defun" in your answer to this lab, and no global variables (I'm trying to steer you clear of the problems I encountered while trying to do this lab myself).
You will almost certainly need to combine several "let" and "flet" forms. Remember that "let" introduces a local variable, and "flet" a local function (sort of like a local function in pascal). For example, if we want a function "foo" to have a local function "double" that it called twice (to quadruple a variable), and then wanted to have foo apply "double" twice to a local variable x, we could do the following:
(defun foo ()
(flet ((double (y) (+ y y)))
(let ((x 5))
(double (double x)))))
Now (foo) returns 20.
HINT - you may want to base your test-scoping function on an example from the book that produces different results based on the type of scoping used (it is appropriate to cite the source of your program in a comment if you do this).
Try out your function to verify that the Common Lisp system we're using uses static scoping (also known as lexical scoping) by default.
Anyone who finds this easy is invited to investigate the "special" declaration in lisp (described on page 223 of Steele's book), and try to produce a variation of your test-scope function that demonstrates dynamic scoping in lisp. Apparently you need to place the form
(declare (special var))
both right after the creation of the variable "var" and inside any function that will use "var", to make use of dynamic scoping for "var". This isn't impossibly difficult, but its somewhat obscure, so its not a required part of this lab.
Your function should be defined in a file with the suffix ".lisp" in your simple-funcs project. Use cvs add (if necessary) and cvs commit to hand in your files.