From: ·········@yahoo.com
Subject: Why this hangs clisp?
Date: 
Message-ID: <1127856231.045464.222140@g47g2000cwa.googlegroups.com>
Hi,

I am using SLIME + XEmacs + CLisp.
I wanted to try CL-FAD package (for file and directory manipulation) so
I wrote this simple test (using mpgtx utility to look at mp3 file
info):

(load "C:/Linux/cl-fad-0.3.2/load.lisp")
(in-package #:cl-fad-test)

(let ((files (list-directory "C:/Music")))
  (dolist (item files)
    (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
    (with-open-stream (*output* (ext:run-shell-command cmd-str :output
:stream))
      (loop for line = (read-line *output* nil)
	    when line do
	    (progn
	      (format t "~a~%" line))))))

It will display the outpout of first mpgtx -i some.mp3 and hang.
I have to go to the Task manager and kill lisp.exe process.
Any suggestions what's wrong here?

Andrei

From: Sam Steingold
Subject: Re: Why this hangs clisp?
Date: 
Message-ID: <uslvqchpv.fsf@gnu.org>
> *  <·········@lnubb.pbz> [2005-09-27 14:23:51 -0700]:
>
> (let ((files (list-directory "C:/Music")))
>   (dolist (item files)
>     (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
>     (with-open-stream (*output* (ext:run-shell-command cmd-str :output
> :stream))
>       (loop for line = (read-line *output* nil)
> 	    when line do

            while line

> 	    (progn
> 	      (format t "~a~%" line))))))

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.openvotingconsortium.org/> <http://pmw.org.il/>
<http://www.camera.org> <http://truepeace.org> <http://ffii.org/>
The early worm gets caught by the bird.
From: Edi Weitz
Subject: Re: Why this hangs clisp?
Date: 
Message-ID: <uhdc6nq6q.fsf@agharta.de>
On 27 Sep 2005 14:23:51 -0700, ·········@yahoo.com wrote:

> (let ((files (list-directory "C:/Music")))
>   (dolist (item files)
>     (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
>     (with-open-stream (*output* (ext:run-shell-command cmd-str :output
> :stream))
>       (loop for line = (read-line *output* nil)
> 	    when line do
> 	    (progn
> 	      (format t "~a~%" line))))))
>
> It will display the outpout of first mpgtx -i some.mp3 and hang.  I
> have to go to the Task manager and kill lisp.exe process.  Any
> suggestions what's wrong here?

I don't know mpgtx but here are some suggestions:

- Why do you need the variables FILES?

    (dolist (item (cl-fad:list-directory "C:/Music"))
      ...)

  will do the same thing.

- You're changing the value of a variable (CMD-STR) that you haven't
  declared before.  This is calling for undefined behaviour, you
  shouldn't do it.

  Again, you don't need the variable:

    (ext:run-shell-command (format nil "mpgtx -i ~A" (namestring item)) ...)

- The PROGN within the LOOP isn't needed.

- You can use WRITE-LINE instead of FORMAT in the last line of your
  code.

- Your inner loop doesn't seem to end - try WHILE instead of WHEN.

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Pascal Bourguignon
Subject: Re: Why this hangs clisp?
Date: 
Message-ID: <871x3ai3im.fsf@thalassa.informatimago.com>
·········@yahoo.com writes:

> Hi,
>
> I am using SLIME + XEmacs + CLisp.
> I wanted to try CL-FAD package (for file and directory manipulation) so
> I wrote this simple test (using mpgtx utility to look at mp3 file
> info):
>
> (load "C:/Linux/cl-fad-0.3.2/load.lisp")
> (in-package #:cl-fad-test)
>
> (let ((files (list-directory "C:/Music")))
>   (dolist (item files)
>     (setq cmd-str (concatenate 'string "mpgtx -i " (namestring item)))
>     (with-open-stream (*output* (ext:run-shell-command cmd-str :output
> :stream))
>       (loop for line = (read-line *output* nil)
> 	    when line do
> 	    (progn
> 	      (format t "~a~%" line))))))
>
> It will display the outpout of first mpgtx -i some.mp3 and hang.
> I have to go to the Task manager and kill lisp.exe process.
> Any suggestions what's wrong here?

Read again your loop.
It doesn't hang, it loops forever.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.
From: ·········@yahoo.com
Subject: Re: Why this hangs clisp?
Date: 
Message-ID: <1127858238.341236.78960@g47g2000cwa.googlegroups.com>
Thank you guys!