Live data from Hacker News

Land Of Lisp chapter 7 - Using SBCL

blog.ciaranbradley.com

1–10 of 15 posts

Re: Land Of Lisp chapter 7 - Using SBCL

#2
I bought the book the other day after it was posted here: http://news.ycombinator.com/item?id=1836935 and have been working through the chapters. The book contains some CLISP specific code but I'm running SBCL. So this is my SBCL hack for the first stumbling block I found.

disclaimer: I'm a LISP noob, so this is a beginners hack, but it may help others (like me) who have had difficulty installing CLISP.

Re: Land Of Lisp chapter 7 - Using SBCL

#4
post #3

Instead of using implementation dependent functions, use a library like trivial-shell, which is also available via QuickLisp. It has the SHELL-COMMAND function you need. http://common-lisp.net/project/trivial-shell/

Cheers, I thought there might be something that was QL installable but didn't want to get sidetracked from the task at hand. I'll have a play with that in the morning :)

Re: Land Of Lisp chapter 7 - Using SBCL

#5
post #3

Instead of using implementation dependent functions, use a library like trivial-shell, which is also available via QuickLisp. It has the SHELL-COMMAND function you need. http://common-lisp.net/project/trivial-shell/

Also, you might find this slow little utility for converting a bunch of stuff into strings. It will do the job nicely, and it accepts every Lisp type.

  (defun str (&rest strings)
    (apply 'concatenate 'string
  	 (loop for x in strings 
               collecting (format nil "~a" x))))

You can use it like this:

  (shell (str "dot -Tpng -O " fname))
You might also find that WITH-OPEN-FILE arguments can get a little unwieldy to type in the repl, specially if you want to overwrite files, so you can use this WITH-TEXT-FILE macro. For binary files you will just need to add (:element-type '(unsigned-byte 8))

  (defmacro with-text-file ((stream path) &body body)
    `(with-open-file (,stream ,path
   			    :direction :io
			    :if-exists :supersede
			    :if-does-not-exist :create)
       ,@body))

Re: Land Of Lisp chapter 7 - Using SBCL

#6
post #3

Instead of using implementation dependent functions, use a library like trivial-shell, which is also available via QuickLisp. It has the SHELL-COMMAND function you need. http://common-lisp.net/project/trivial-shell/

Cheers, I thought there might be something that was QL installable but didn't want to get sidetracked from the task at hand. I'll have a play with that in the morning :)

Enjoy yourself!

Of course, you're more than welcome to shoot me an email if you ever get stuck.

Here is a far more forgiving reference to Common Lisp than the Hyperspec, though don't let the fancy TeX typesetting intimidate you.

http://clqr.berlios.de/clqr-a4-consec.pdf

In addition to that, I think you should dump yourself a nice image with ASDF and QL builtin, so you don't have to load them every time.

Re: Land Of Lisp chapter 7 - Using SBCL

#10
post #5
post #3

Instead of using implementation dependent functions, use a library like trivial-shell, which is also available via QuickLisp. It has the SHELL-COMMAND function you need. http://common-lisp.net/project/trivial-shell/

Also, you might find this slow little utility for converting a bunch of stuff into strings. It will do the job nicely, and it accepts every Lisp type. (defun str (&rest strings) (apply 'concatenate 'string (loop for x in strings collecting (format nil "~a" x)))) You can use it like this: (shell (str "dot -Tpng -O " fname)) You might also find that WITH-OPEN-FILE arguments can get a little unwieldy to type in the repl…

How about simply this?

  (defun str (&rest strings)
    (format nil "~{~A~}" strings))
Post reply on HN