NewsLab
Jun 28 20:17 UTC

Slisp: Simple Lisp compiler (Linux/amd64) (github.com)

66 points|by stevekemp||8 comments|Read full story on github.com

Comments (8)

8 shown
  1. 1. stevekemp||context
    Hacker News always likes lisp stuff, and even though this is a very simple compiler I had a lot of fun writing it.

    I started writing a different compiler, but tied myself in knots with the type-encoding, and lack of clear plan. I figured I'd step back and try a lisp, because there's a known syntax, and it is minimal.

    The end result supports lists, integers, strings, characters, lambdas (with closures), and a reasonable standard library - big enough to hack up a small brainfuck interpreter along with the standard fibonacci, factorial, and fizzbuzz toy programs.

    So it's a toy, but it's my toy, and maybe interesting to some!

  2. 2. phyzix5761||context
    I started working on a Lisp interpreter in Python a few days ago so its really nice to see your implementation.

    If you're interested here's my repo: https://github.com/lodenrogue/hith

    Its very early stages and missing a lot of key features but its been a lot of fun figuring stuff out. Will definitely study your source code to learn more.

  3. 3. stevekemp||context
    That's really nice. Even with your limitations you have things I don't, for example quoting and booleans.

    There's a part of me that thinks your comparisons should return "Nil" on failure rather than "False", but it also seems logical to do it your way too!

    I hope you stick with it :)

  4. 4. phyzix5761||context
    Yeah, thats a good observation. I wanted to keep the Python types like True, False, and None since its built for Python. That made more sense to me so that users could easily embed it into their Python scripts.
  5. 5. bsder||context
    That's a Lisp vs Scheme kind of thing. Also, being able to take the cdr of an empty list is a Lisp vs Scheme thing.
  6. 6. krylon||context
    Just as I was thinking to myself that it might be fun to play around with Lisp again, this shows up in my news ticker. Coincidence?
  7. 7. stevekemp||context
    There was a repost of Peter Norvig's lisp interpreter in python a week ago too:

    https://news.ycombinator.com/item?id=48619831

    That came just around the time I was struggling with my "real" language, and switched to working on this lisp compiler.

    Sometimes timing works out well to inspire!

  8. 8. krylon||context
    Some years ago - never mind how long precisely - I also starting writing a Lisp interpreter in Python. I also called it Lispy. This time, the coincidence is less remarkable though, as the word play just sits there, begging to be played.