I wrote the function
(defun test () (let ((str1 'foo') (str2 'bar')) (loop for s in '(str1 str2) do (message s))))
but it does not work. The Elisp Backtrace message is:
Debugger entered–Lisp error: (wrong-type-argument stringp str1)
How can I make it work?
P.S.: the following modified version works perfectly, but I need the original version
(defun test1 () (loop for s in '('asdf' 'fdsa') do (message s)))
The
quoteoperator (for which the apostrophe is syntactic sugar) means that its arguments are not evaluated, i.e.(quote (str1 str2))returns a list of two symbols. Uselistinstead:(list str1 str2).