A lisp question here. I've been slowly learning lisp over the last couple of months and have ran into a problem when trying to grab input from a web browser vs. grabbing input from a REPL.
The specific problem is when trying to evaluate this code:
Assume sexp is '(look north).
(member (car sexp) '(look walk pickup drop))
From the REPL in SBCL this works fine and as expected. However, when grabbing the sexp from hunchentoot even though sexp "looks" like it is the same as from the REPL it never seems to be able to consider the result of (car sexp) a member of '(look walk pickup drop).
I think it might be the character encoding of the file vs. character encoding of sexp when grabbed from the web browser but I have no idea how to test this hypothesis. Any pointers would be much appreciated!
Edit
The way I take the input in is based on based on the text adventure game from "Land of Lisp" by Conrad Barski and is detailed below.
(defun game-read (string-to-read)
(let ((cmd (read-from-string
(concatenate 'string "(" string-to-read ")"))))
(describe cmd)
(flet ((quote-it (x)
(list 'quote x)))
(cons (car cmd) (mapcar #'quote-it (cdr cmd))))))
This is then wrapped in:
(defun game-eval (sexp)
(if (member (car sexp) *allowed-commands*) ;Offending line
(eval sexp)
'(i do not know that command.)))
where *allowed-commands* is:
(defparameter *allowed-commands* '(look walk pickup inventory))
The line that I have labelled as offending the one that works fine normally but when the string-to-read is from a request parameter fetched from hunchentoot as part of a request (car sexp) looks the same any way I know how to look at it but is not found in *allowed-commands*.