domingo, 23 de enero de 2011

I can has HAS (Half Assed Scheme)


If you've been reading along these bloglines, you already know I'm on
my way to learn lisp, and given that a typical exercise on the lispers
path is writing a scheme interpreter, I decided to try to impement a
scheme interpreter in perl. I had a great guidance of Peter Norvig's lispy tutorial, and more thoughtful explanations from Bill Hails' book.




I can't say I wrote it as quick as I thought I would, and it could
definately be clearer (OOP in such small projects is clearly
overengineering), but in the end, it works, and given the fact that I
hadn't been programming perl at work for 2 months, it's been a good exercice.



The relevant code is in 4 files,


  • script/lis.pl (REPL and primitives),

  • lib/hascheme/Reader.pm (Parsing)

  • lib/hascheme/Env.pm (environment, a tree structure built on hashes)

  • lib/hascheme/Evaluator.pm (special operators are treated here, and overall evaluation)



Anyway, here you are, the code is in a github repo. For now, It's
called half assed scheme, or hascheme, or HAS.

Related article: next post on HAS


Now, you can has HAS too.