I want to hide as a local a helper function within its parent function.
Next I tried this:
;Compiler warnings for "/Users/charlesparker/Code/Lisp/TryIt.lisp" :
; In MY-REVERSE: Unused lexical variable FUNCTION
;Compiler warnings for "/Users/charlesparker/Code/Lisp/TryIt.lisp" :
; In MY-REVERSE: Unused lexical variable FOO
but my-reverse seems to work:
? (my-reverse '(1 2 3))
(3 2 1)
however, so does this:
(foo '(1 2 3) nil)
(3 2 1)
I assumed locally defined functions would have similar scoping rules as locally defined variables. What's the deal?
Thanx - Charlie
(defun fubar (x)
(defun feebar (y)
...)
...)
doesn't work because feebar becomes a global (at least it's global in the REPL which is my sandbox).Next I tried this:
;; my-reverse
(defun my-reverse (ol)
(let (foo #'(lambda (x y)
(if (equal x nil)
y
(foo (rest x) (cons (first x) y)))))
(foo ol nil)))
which generates these compiler warnings I don't understand:;Compiler warnings for "/Users/charlesparker/Code/Lisp/TryIt.lisp" :
; In MY-REVERSE: Unused lexical variable FUNCTION
;Compiler warnings for "/Users/charlesparker/Code/Lisp/TryIt.lisp" :
; In MY-REVERSE: Unused lexical variable FOO
but my-reverse seems to work:
? (my-reverse '(1 2 3))
(3 2 1)
however, so does this:
(foo '(1 2 3) nil)
(3 2 1)
I assumed locally defined functions would have similar scoping rules as locally defined variables. What's the deal?
Thanx - Charlie