Lisp in Python as a library (not crossposted)

V

Ville Vainio

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
 
R

Robin Becker

Alan Gauld said:
Danny Yoo did a basic Scheme or Lisp intrpreter in Python a few
years ago - it may be on the Useless Python website...???


Are you listening Danny?

Alan G.

Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
I wish all the lisp versus python wars would go away, but if they really
want to do 'my language is bigger than your language' then cross
language translation is the way to go. Then they can argue about code
size efficiency etc in some reasonable way. Assuming both languages are
Turing complete probably eliminates most of the arguments anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top