Sly Lisp program only shows first prompt

206 views Asked by At

I'm following along with the book Practical Common Lisp and I'm getting unexpected behavior. The code is the following:

(defun prompt-read (prompt)
  (format *standard-output* "~a: " prompt)
  (force-output *standard-output*)
  (read-line *standard-input*))

(defun prompt-for-cd ()
  (make-cd
   (prompt-read "Title")
   (prompt-read "Artist")
   (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
   (y-or-n-p "Ripped [y/n]: ")))

The program is supposed to prompt a user for a title, accept a title, prompt a user for an artist, accept an artist, etc. until the user has entered all the information. Just running prompt-read in the REPL successfully prompts the user for the desired prompt and returns the result. However, this is my output from running prompt-for-cd: enter image description here

My program still accepts input, but it stops prompting the user after the first prompt.

Compiling and loading the file where I define the functions seems to show the prompts that should have been shown to the user the last time I ran prompt-for-cd. Here's a screenshot of what that looks like: enter image description here

After some investigation, I noticed that this is only happening in Sly's REPL. Here's the output of the program when I just load the file with SBCL: enter image description here

How can I get console prompts to work as expected in Sly?

0

There are 0 answers