Is there any Lisp function that can pause a Lisp program's execution
for a few seconds, maybe something like (pause 5), which would cause
the program to pause for 5 seconds. I am writing a program that uses a
socket stream to input/output data. After outputting to the stream, it
takes a few seconds before there is anything to read from the stream.
I might be able to use threads or something else, but a pause function
would be great. Thanks.
On Apr 4, 6:35 pm, dstein64 <········@gmail.com> wrote:
> Is there any Lisp function that can pause a Lisp program's execution
> for a few seconds, maybe something like (pause 5), which would cause
> the program to pause for 5 seconds. I am writing a program that uses a
> socket stream to input/output data. After outputting to the stream, it
> takes a few seconds before there is anything to read from the stream.
> I might be able to use threads or something else, but a pause function
> would be great. Thanks.
(sleep seconds)
http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node232.html
dstein64 wrote:
> Is there any Lisp function that can pause a Lisp program's execution
> for a few seconds, maybe something like (pause 5), which would cause
> the program to pause for 5 seconds. I am writing a program that uses a
> socket stream to input/output data. After outputting to the stream, it
> takes a few seconds before there is anything to read from the stream.
> I might be able to use threads or something else, but a pause function
> would be great. Thanks.
http://www.lisp.org/HyperSpec/Body/fun_sleep.html
--
Lars Rune N�stdal
http://nostdal.org/
d> socket stream to input/output data. After outputting to the stream, it
d> takes a few seconds before there is anything to read from the stream.
d> I might be able to use threads or something else, but a pause function
d> would be great. Thanks.
it's better not to depend on particular timing -- this can cause problems if
it goes not as expected.
but good news you don't need to use threads or something else -- normal read
should wait until data arrives, it's called "blocking read".
maybe just lisp you're using is broken? or you're using non-blocking
functions, like read-char-no-hang?
if you'll take a look on this examples for CLISP
http://clisp.cons.org/impnotes/socket.html
you can see there is no pauses, no threads or anything else -- they just
call read-line, and it works.