4

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?

coredump
  • 37,664
  • 5
  • 43
  • 77
Anthony Bias
  • 515
  • 3
  • 20
  • 3
    https://github.com/joaotavora/sly/issues/426 and https://github.com/joaotavora/sly/issues/347 looks like exactly your problem (MacOSX?) – coredump Nov 09 '22 at 08:58
  • 2
    the simplest answer here is starting your slynk server separately and connecting with "sly-connect" instead of starting sbcl when running "sly", and/or disabling the use of a dedicated stream : `(setf slynk:*use-dedicated-output-stream* nil)`: https://github.com/joaotavora/sly/issues/196 – coredump Nov 09 '22 at 09:01
  • 1
    I can't edit the tag due to too many pending edits, but the [tag:sly] tag is for the Lex/Yacc Python replacement. – Sean Duggan Nov 11 '22 at 23:57
  • 1
    @SeanDuggan I edited the tags but its a shame that tagging works like this – coredump Nov 14 '22 at 08:52

0 Answers0