|
|
|
|
|
by ohyes
2498 days ago
|
|
Here you go. (defvar *my-variable* nil)
(let ((jump-table (vector (lambda () (list 'a *my-variable*))
(lambda () (list 'b *my-variable*))
(lambda () (list 'c *my-variable*))
(lambda () (list 'd *my-variable*)))))
(defun jump-table-caller3 (i)
(let ((*my-variable* i))
(funcall (aref jump-table i)))))
It's getting late for me so I'm headed to sleep, but this has been interesting, thanks! |
|
You will quickly find that this also will not work, for if a closure was made inside of each branch, the environment would not be shared among them.
The original intent of this exercise was to demonstrate you can’t macro your way out of all deficiencies in Lisp. And certainly in this case, even if we were to accept this dynamic variable rigamarole, we would find that we could not write a macro that, e.g., replaces CASE.