Hacker News new | past | comments | ask | show | jobs | submit login
Port of PG's "On Lisp" to Clojure (thinkrelevance.com)
80 points by ecounysis on Aug 21, 2011 | hide | past | favorite | 8 comments



Michael Fogus has also done some work porting On Lisp to Clojure. Chapters 2-5 are here: http://blog.fogus.me/tag/onlisp/

Halloway picked up where Fogus left off.


Is the github repo (https://github.com/stuarthalloway/onlisp-clojure) not being used by both of them ?

It's a wee bit scattered all over the place.


I would absolutely love a more advanced Clojure book in the same vein as "On Lisp", especially if Stuart Halloway is in any way involved. Most of the content can probably be pretty similar modulo differences in the macro systems and such (probably have to axe the reader macros chapter...)


Note that this is from 2008, so some of the code samples are out-of-date (e.g., case is now part of clojure.core).


chapter 9 is particularly useful. clojure doesn't have hygienic macros, but it does have namespaces, so it is not as likely as common lisp to silently introduce naming problems. that's explained quite well there (better than i have found anywhere else).


Pardon, I don't know Clojure inside and out: are namespace significantly better than packages for the purpose of macro hygiene?


namespaces in combination with how syntax-quote (`) autoqualifies symbols and let disallowing qualified identifiers makes it noticeably more difficult to introduce a name clash.

for example the following macro results in an error when you try to run the expanded code: (defmacro ex [x] `(let [y 1] (~x y)))

because it expands to (let [namespace/y 1] ...) which is disallowed. When you need to, there is a way to force an unqualified symbol by explicitly quoting and unquoting a symbol, and ` provides autogensyms, so it is very convenient to use.

Namespace-qualifying also means that post-expansion changes to your local namespace won't change the meaning of symbols that referred to things in an external namespace when the macro was expanded.


That's great! Thanks, Stuart, for doing this. When I was read PG's "On Lisp", I kept wishing the examples were in Clojure.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: