Cool. I have been working through the lessons in Nathan's University (http://nathansuniversity.com/) which take you writing a Lisp interpreter (though admittedly with less rigor than this project) in Javascript.
Definitely recommended if you want a starting point for something similar and don't know where to begin.
I found one bug: you cannot create a zero argument lambda, e.g. (lambda () 42) will not work. You could also benefit from separate `let' construct, because simulating them with lambdas is a bit painful.
Apart from that, it works quite nicely (I was positively surprised you went for lexical scoping), but without macros, you can hardly say it's a Lisp, it's a language with Lispy syntax.
He was a regular poster on comp.lang.lisp, and one of the contributors there described him thusly:
"Ken Tilton is an aquired taste - if you can ignore his inflammatory remarks his advice is usually good. When I first saw some (most!) of his posts I initially thought WTF! but think of him as someone with Tourettes Syndrome and just look at what he is saying not how he is saying it!"
There's a couple of fortune cookie files of quotes from him (collected by someone else, but you can find them on his blog), they do make for funny reading, but you can see how some of this would sting if the remarks were directed at you:
http://smuglispweeny.blogspot.co.uk/2010/08/fortune-cookie-f...
Gotta shout out to my own Lisp-in-JavaScript interpreter from long, long ago: http://joeganley.com/code/jslisp.html ... far less complete than this, but perhaps interesting to someone for archeological reasons or something.
19 comments
[ 2.9 ms ] story [ 56.6 ms ] threadDefinitely recommended if you want a starting point for something similar and don't know where to begin.
Apart from that, it works quite nicely (I was positively surprised you went for lexical scoping), but without macros, you can hardly say it's a Lisp, it's a language with Lispy syntax.
> without macros, you can hardly say it's a Lisp, it's a language with Lispy syntax.
These two things go together: many lisps have let as a macro that uses lambda internally.
> I was positively surprised you went for lexical scoping
Indeed; that makes for a much more usable language.
My goal here was to learn how Lisp works at a really low level. I'm planning to add the features you would expect from a Lisp (e.g. macros) very soon.
Your interpreter would be even more awesome if its interface was a file buffer instead of a toplevel. But so far, great work!
It's more Scheme influenced (but not at all RnRS compliant) and as of about half an hour ago has working define-syntax/syntax-rules style macros.
The code isn't as nice though ;). I just wanted to get it working so I could rewrite it in itself.
There is a slight bug though. Since the position gets updated after the position is calculated, the displayed value is out of sync.
So entering
1
2
3
And then typing: UP (3), UP (2), DOWN (1)
Displays 1, rather than 3.
http://common-lisp.net/project/cells/
"Ken Tilton is an aquired taste - if you can ignore his inflammatory remarks his advice is usually good. When I first saw some (most!) of his posts I initially thought WTF! but think of him as someone with Tourettes Syndrome and just look at what he is saying not how he is saying it!"
There's a couple of fortune cookie files of quotes from him (collected by someone else, but you can find them on his blog), they do make for funny reading, but you can see how some of this would sting if the remarks were directed at you: http://smuglispweeny.blogspot.co.uk/2010/08/fortune-cookie-f...