I have a function that I’m trying to compile, but I’ve been pulling my hair out for the last 30 minutes trying to figure out why this code is giving me a Undeclared free variable error. I’m using Emacs, and cannot decipher why I’m getting this error.
(defun pretty-all(res diff)
(let* ((v-list (blank-unit-list res))
(c-list (blank-unit-list res)))
(complete-fill c-list v-list res (total-res res) diff)
(format t
"Resistance is ~S~% Voltage is ~S~% Current is ~S~%"
res v-list c-list)))
blank-unit-list , complete-fill , total-res are all my custom-defined functions.
I’m pretty sure this error is related to how I structured my code, but as I’ve said before, I can’t figure out what.
Copied from Emacs:
3 compiler notes:
CircuitFunctions.lisp:61:64:
warning: Undeclared free variable RES
CircuitFunctions.lisp:61:70:
warning: Undeclared free variable V-LIST
CircuitFunctions.lisp:61:81:
warning: Undeclared free variable C-LIST
Compilation failed.
Following wvxvw’s suggestion that my code might have a missing parens somewhere, I scrolled through my file with
C-M-f. It passed through without a problem and by now I was starting to give up. Lastly, just to make sure, I copied the code from this question and replaced my previous function with the one here. Somehow it works now. I don’t know what it was that caused the problem, but it functions correctly now. Thanks everyone for their input.