2

My goal is a function that collects info from the user.

So far I have this:

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

Witch outputs:

CG-USER(27): (prompt-read "cenas")
cenas: lol

"l"
T

There are 2 things I dont understand here:

1 - Why is read-line only getting the first character?

2 - Why do I have to press ENTER twice after writing the string "lol" for the function to work?

I'm using Allegro CL Free Express Edition 9.0 and windows 8 - 64 bits.

EDIT: After trying this in a linux machine the output was what I expected and only one ENTER was required, however I would still like to understand this behavior on the windows environment.

pedromss
  • 2,443
  • 18
  • 24
  • 3
    This is a [known problem](http://stackoverflow.com/a/14583086/800524), you have to update Allegro CL. – acelent Dec 01 '14 at 17:17

1 Answers1

1

I tried your example on CCL (Linux) and Allegro Enterprise Edition 9.0 (Linux) and in both cases it returned:

"lol" NIL

The NIL may be informative, as it differs from your output -- you got T, which means missing newline, which is very strange.

http://clhs.lisp.se/Body/f_rd_lin.htm

Unfortunately without a Windows environment to try this in, I'm not sure what to suggest, beyond that this might perhaps be some kind of issue with your terminal, newline encoding, or something like that.

Jared Davis
  • 559
  • 4
  • 12
  • I tried my code in a Ubuntu VM and it worked like in your case, only 1 ENTER required and read-line got the whole word. However if you, or someone else, has any tips as to how to find out the problem on the windows environment I would be thankful. – pedromss Nov 29 '14 at 13:31