I have been extremely busy the last couple weeks, but when I find a scrap of spare time, I have been surrounding myself with little Lisp projects.
Most recently, I wrote a little prototypical object system for CL yesterday. I have named it protolith, and here is the description I gave on GitHub:
Just for exploratory fun, I decided to see what it takes to write a prototypical object system in Lisp. Apparently its not much, I'm far from an experienced Lisper (barely fluent, if that) and I got it done in ~50 lines. A testament to Lisp's flexibility and expressiveness.
And here is a small example:
CL-USER> (load "/home/fitzgen/dev/protolith/protolith.lisp") T CL-USER> (in-package :protolith) #<PACKAGE "PROTOLITH"> PROTOLITH> (defobj account () (bal 0) (deposit (lambda (self x) (funcall self 'set 'bal (+ (funcall self 'bal) x))))) ACCOUNT PROTOLITH> (account 'bal) 0 PROTOLITH> (account 'deposit 50) 50 PROTOLITH> (account 'bal) 50 PROTOLITH> (defobj checking-account (account) (withdraw (lambda (self x) (progn (funcall self 'set 'bal (- (funcall self 'bal) x)) x)))) CHECKING-ACCOUNT PROTOLITH> (checking-account 'bal) 50 PROTOLITH> (checking-account 'withdraw 10) 10 PROTOLITH> (checking-account 'withdraw 10) 10 PROTOLITH> (checking-account 'bal) 30 PROTOLITH> (checking-account 'proto) #<CLOSURE ACCOUNT>
(Side note: For this site, I highlight syntax on the client-side with SHJS, but,
as you can see above, they don't support syntax highlighting for Lisp. I'm
thinking of moving towards writing a Pygments
Django template filter that finds
<pre> tags automatically and
highlights the contents appropriately. If anyone has any other
ideas shoot me an
The other Lisping I have been doing is writing
my boostrap scheme interpreter in
Ada. Peter Michaux finished his series, and now I am just playing catch
up. As of this moment, the printer, reader, and evaluator are complete, and it
is just a matter of writing the proper primitives and special forms for the
evaluator and I'm done. So far, I have
or, and a
bunch of others, notably
lambda still to come.
fitzgen@shaolin:~/dev/ada-scheme $ ./scheme Welcome to Bootstrap Scheme -- Ada version. > (define foo #t) ; ok > foo ; #t > (if foo "hello" "goodbye") ; "hello" > (set! foo #f) ; ok > (if foo "hello" "goodbye") ; "goodbye" > foo ; #f >
That's all for now, more updates to come soonish.