Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool to translate Lisp code into Python? [closed]

Because I want to use Lisp's syntax and Python's libraries.

Maybe some tools like Parenscript but generates Python code instead of Javascript.

like image 433
SaltyEgg Avatar asked Aug 31 '13 05:08

SaltyEgg


1 Answers

I've been experimenting a bit with a Lisp compiler targeting Python bytecode.

You can see a small video here.

It's just a proof-of-concept toy but it's IMO a viable path and the end result would be able to call and be called from python freely (and it would be compatible with any python extension library). All this keeping however the power of macros (metaprogramming is probably the area in which Python is farthest from lisp).

Targeting Python source code instead is quite more annoying to do because there are explicit syntax limitations that make compiling Lisp difficult (e.g. assignment is not an expression, no statement is permitted in lambda, captured variables are read-only in Python 2.x).

The VM runtime however doesn't have these limitations and Python bytecode is reasonably nice.

My toy currently can target Python 2.x, Python 3.x and works even with PyPy (so you get a JIT compiler too).

Of course aiming at becoming a full compliant Common Lisp implementation would be IMO nonsense from a technical point of view, but a lisp dialect based on Python runtime types and compatible with Python object system could instead be a reasonable tool with practical applications.

like image 147
6502 Avatar answered Sep 24 '22 00:09

6502