Lisp in Python as a library (not crossposted)
Ville Vainio
ville.spammehardvainio at spamtut.fi
Tue Oct 21 02:39:04 EDT 2003
Apparently there is some kind of toy Lisp interpreter written in Python:
http://www.biostat.wisc.edu/~annis/creations/PyLisp/pylisp.html
However, how about extending the idea? I.e., making all the Python
functions callable from Lisp, and having all the objects in Lisp
actually be Python objects (using some classes like cons cells etc.):
-----------------------------
lst = readlisp("""(defun sum (x y) (+ x y))""")
# lst == <cons cell at 0x123>
ns = mk_lisp_namespace() # this has lambda, defun, defmacro & friends
eval (lst,ns)
# ns["sum"] == <cons cell>
def sum2(x,y):
return x+y
ns["sum2"] = sum2
s = evallist("(sum2 2 3)",ns)
# s == 5
---------------------------------
Sounds like a nice way to bring us all the macro power our Lisp
friends glorify so much, and a way to end all the inter-newsgroup
flamewars once and for all :-).
--
Ville Vainio http://www.students.tut.fi/~vainio24
More information about the Python-list
mailing list