4

I'm trying to learn Lisp by reading Practical Common Lisp and I've hit a small stumbling block early on when trying to read user input. I've defined prompt-read to prompt the user for input:

(defun prompt-read (prompt)
  (format *query-io* "~a: " prompt)
  (force-output *query-io*)
  (read-line *query-io*))

When I try to evaluate prompt-read, pressing [Enter] to run the statement seems to be accepted as the input so the resulting input is blank

>(prompt-read "Test")
Test: 
""
NIL

I followed the example exactly, so I'm assuming that this is somehow related to my environment. I am using Emacs Inferior Lisp in Windows, is there some adjustment I have to make to my code in order to get the behavior I expect?

1 Answer 1

3

There seems to be nothing wrong with your code, and it also correctly runs with e.g. SBCL on MS Windows. Instead of inferior lisp mode (that is really inferior) why don't you give a try at using SLIME to edit and run your CL code inside Emacs? You can install it quickly by following this guides:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I'll try SLIME tonight to see if that resolves my issue. I didn't bother with it up front since various sites recommended using the default inferior mode while learning / exploring the language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.