Willem Broekema, with support from Franz, has developed CLPython, a Lisp implementation of Python [via Stefan Scholl].
Posted by jjwiseman at July 05, 2006 12:22 PMA large part of the Python language features is implemented by CLPython (basic data types, functions, classes, metaclasses, generators, closures, ...). Many recently introduced features are still missing (e.g. "y = yield x"); the intention is of course to add these features to CLPython.
Below, a sample interaction with the read-eval-print loop is shown.
python(7): (repl) [CLPython -- type `:q' to quit, `:help' for help] >>> print "hello world!" hello world! >>> def fact(n): ... if n <= 1: ... return 1 ... else: ... return n * fact(n-1) ... #<python-function fact @ #x71d67c9a> >>> fact(6) 720 >>> :q Bye
This is such a cool project.
Posted by: Tom on July 5, 2006 02:06 PMVery cool, indeed. Btw, does anybody know what happened to the Python in Smalltalk implmentation by Peter Deutsch?
Posted by: kasper on July 6, 2006 04:10 AMYears ago I had some undergrads go the other way: integrate all the python C libraries into scheme. Then one could build high-level Scheme libraries on top of all that low-level C code. Turns out it was very easy to implement and it was quite useful. I'm surprised noone else has tried this.
Surana,
Could you give some clues on how you did it, please?
The Python-to-C API requires that C libraries expose a particular API so Python can load and call it. Simply use your FFI (we used scheme48) to load and call those C libraries the same way Python would. They allow C to pass back a few python datatypes back, so you write a translator or a wrapper in Scheme to expose them to your Scheme code. Obviously, you can't reuse the Python libraries built on top of these low-level libraries, but you get immediate access to all the services outside your language bubble: OS, databases, graphics, networking, etc. Much easier than writing all this stuff yourself.
If you're interested, send mail to suranap at gmail and I'll try to dig it up.
Posted by: surana on July 8, 2006 04:50 PM