Friday, September 3, 2010

multithreaded trace in sbcl, and info about load

Coming from a C++/all things with braces and semicolons background, all things lisp are still quite confusing. Here's my latest gems that I found:

*default-pathname-defaults* will be the directory from which sbcl is launched. When you call (load "somefile.lisp"), it needs to be in the directory specified by *default-pathname-defaults* because you did not specify an absolute directory. As it turns out, the "working directory" according to your lisp implementation may have little or nothing to do with the OS "working directory" for that process. Just another oddity where lisp has decades of diverging behavior from everyone else on the planet.

If I start sbcl from the Terminal (by just typing "sbcl" and hitting enter), I can try this command:

(sb-thread:make-thread (lambda () (format t "hello from a thread~%")))

and I will see the output. But from swank (which is used by slime, cusp, MCLIDE, virtually anything except possibly lispworks or the corman lisp ide), you'll only see some syntax describing a thread, and possibly NIL, which describes the return value of that lambda expression.

If you happen to have textmate installed and can launch it with the command "mate" from your Terminal, then you can mate ~/.swank.lisp and add this one line to the possibly empty file:

(setq swank:*globally-redirect-io* T)

This works for MCLIDE, and probably works for everything else too. With this line, I can see:

Welcome to SBCL 1.0.39!
? (sb-thread:make-thread (lambda () (format t "hello")))
#
hello
?

Without that ~/.swank.lisp file, I would not see the "hello" line.

As always please leave comments or questions if you need help getting lisp up and running on your laptop. I am part of the new guard, those who are happy to help other lisp newbies without being insulting. Erik and those other guys are probably brilliant minds, but they were a pain in the ass, and sometimes I think that common lisp reflects that mindset in some ways.

0 comments:

Post a Comment