Hacker News new | past | comments | ask | show | jobs | submit login
Adder: Python with a Lisp (thibault.org)
53 points by metageek on Jan 23, 2011 | hide | past | favorite | 16 comments

This is the language I presented two years ago at the 2009 International Lisp Conference. It's finally ready for people to try out.

From the documentation:

Adder is a Lisp-1 which compiles to Python. It aims to integrate seamlessly into Python: every Adder function is a Python function, every Adder list is a Python list, etc.

Python-on-Lisp has been tried before; I think Adder has two advantages that previous attempts did not. The first is technical: Python's metaprogramming has gotten better in the past few years, which allows Adder to integrate more smoothly. The second is social: Clojure has prepared the ground for the notion of a Lisp that integrates into an existing language.

It has one bit of non-Lispy syntax: foo.bar.baz means exactly what it does in Python, and .bar.baz is a function, defined so that (.bar.baz foo) is identical to foo.bar.baz.

Hi, thanks -- this looks great!

Does it support tail recursion (in constant space)?

No, because it compiles to Python. I suppose I could finagle some way to manage it for self-calls, by putting the whole function in a loop.

Although that would bind the function name earlier than usual for Python. In Python, you can (in theory) do this:

  def fact(n,sofar):
    if n<2:
      return sofar
      return fact(n-1,n*sofar)

  fact=lambda n,sofar: 3
...whereupon f(7,1)==3. I suppose I wouldn't really mind if Adder broke that consistently, but I don't think I like the idea of breaking it only for functions that do self-tail-calls.

Have you considered using a "trampoline" function like this?


You'll get a lot out of _Lisp in Small Pieces_ (http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiS...), as well.

Python wouldn't be my first choice, and I'm unconvinced that Lisp-Py makes sense, but I'm sure you'll find ways to adapt it regardless.

Interesting...no, I hadn't seen that before. I'll think about it.

How about considering Clojure's style of using recur to support self-tail-call optimization using explicit syntax?

Hmm. Maybe. I'd have to look closer.

My main resistance is that I've used languages where you have to use special syntax for a recursive function, and I hate it. But this isn't quite the same thing.

Does it really make sense to add a workaround-to-a-workaround?

A flag to enable targeting stackless python instead of normal python?

I gave it a quick look and I wonder why would I want to use it? I am a fan of both lisp and python and enjoy trying new languages but why would I want to use it instead of one of those languages? What exactly cool features does it offer?

Well, the main one is that you combine access to Python libraries with Lisp macros.

In case you're wondering, you can also put your Python in a Lisp:


I have an unreleased/unfinished Scheme to Python interpreter, which is intended to be a full compiler. I'm using trampolining for everything as I wanna be able to support call/cc at some capacity, so there's a factor of slowdown to using it, but it's pretty fun nevertheless.

Interesting. The name isn't the best to google for, though...

True. It comes up as #2 and #3 if you google for "adder lisp", though.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact