Land Of Lisp chapter 7 - Using SBCL
Over the past few evenings, I've been working through Conrad Barski's "Land of Lisp" book (available at http://nostarch.com/lisp.htm I recommend you watch his groovy video at http://landoflisp.com).
Some of the code in the book is specific to CLISP, however I'm running SBCL, and I thought it might be easier to port the code rather than faff about installing CLISP. In the book, the code is:
(defun dot->png (fname thunk)
(with-open-file (*standard-output*
fname
:direction :output
:if-exists :supersede)
(funcall thunk))
(ext:shell (concatenate 'string "dot -Tpng -O " fname)))
Most of this block seems to work fine. it's the call to the shell command to run "dot" that isn't cross platform.
(ext:shell (concatenate 'string "dot -Tpng -O " fname)))
that isn't cross platform.With a bit of googling, and trial and error, I have changed the last line, so that it now uses sb-ext:run-program, which I'm presuming is the closest match. You will need to know the path to your graphviz installation, but the new code should look something like this:
(defun dot->png (fname thunk)
(with-open-file (*standard-output*
fname
:direction :output
:if-exists :supersede)
(funcall thunk))
(sb-ext:run-program "/usr/local/graphviz-2.14/bin/dot" (list "-Tpng" "-O" fname)))
Running it produced the png as expected in the chapter.I will defer to any experienced LISPer on whether it's best practice to use this command in this way.
Edit: It's always good to ask :) I posted this over on HN last night, and this morning I was greeted with a number of great suggestions on how to proceed that should fix the cr: http://news.ycombinator.com/item?id=1851948
Also if you have ASDF, check out the two liner in the comments provided by fahree.
All of which goes to show me that there is more than one way to skin the proverbial cat in CL, so if one doesn't work out for you all is not lost.

