Hacker News new | ask | show | jobs
by yummyfajitas 6139 days ago
Something I've never gotten around to is building an algolish-lisp -> lisp translator.

    [a, b, c] -> '(a b c)

    f(x) -> (f x)
These two translations are strictly syntatic modifications to lisp.

Some syntactic sugar:

    {
        f(x)
        g(x)
    } ->
    (progn
        (f x)
        (g x)
    )
With these three tweaks, we are probably 90% of the way to recruiting the common man (if syntax is really what puts them off).
4 comments

You can do these within PLT scheme quite easily. In fact, PLT Scheme comes with an Algol 60 reader that reads Algol 60 and turns it into scheme forms which are then executed. It's a cute trick.

http://docs.plt-scheme.org/algol60/index.html

This looks great for trivial code, but what about more complex code?

    destructuring-bind([a b &rest c] some-list lambda([x] +(a b x)))
or

    loop(for i from 1 to 10 collect 1+(i))
or

    with-current-buffer(get-buffer-create("foo")
      save-excursion(
        insert(text)
        buffer-substring-no-properties(point-min() point-max())))
This looks horrible. There is an advantage in using the same syntax for both lists and function application.
I've done things like this in Scheme - not robustly, but it's worth pursuing IMHO. I can't stand math formulas in SEXP notation. Array/slice/hash lookup notation would be nice too.

Lisp gets it right by excluding sugar from the language kernel, but a "batteries-included Lisp" should include it in a standard library.

I tried this with arc (worked with anarki based in arc2)

http://arclanguage.org/item?id=8172

The syntax is inspired by McCarthy's in his paper from 1958. It works, but i don't find it useful.