I write a script with using random and with-open-file, it works well in slime by emacs. But it cannot work when I use sbcl compile it to a execute file.
Code:
(defun choice-file-to-open (files)
(let ((filePath (nth (random (length files)) files)))
(open-by-system filePath)
(with-open-file (file "./logs" :direction :output
:if-exists :append
:external-format '(:utf-8 :replacement #\?))
(format file "~S~%" (namestring filePath)))))
open-by-system
is a function to open file.
My purpose is pick random file in the folder. But it always choice the same file to open when I use it. Only for the singer execute file, the slime work well.
Then I add the log file to record the filename every time I open. But there is no log file, as same as problem before, this problem only issues in executed file, and code works well in slime.
I found the answer (Random) in Common Lisp Not So Random? and it cannot solve the random problem.
What wrong with me? There are many differences between slime and sbcl?
Aucun commentaire:
Enregistrer un commentaire