Hacker News new | past | comments | ask | show | jobs | submit login
5 minutes Lisp in Python (gist.github.com)
21 points by pepijndevos on Sept 10, 2010 | hide | past | favorite | 7 comments



  (loop (print (eval (read))))
3-second Lisp ;-)


Great starting point even if it's not all the way to Lisp :) Shouldn't be too hard to add the rest - read the SICP on the meta-circular evaluator and translate http://mitpress.mit.edu/sicp/full-text/sicp/book/node76.html


That'd be nice... Write the current function to the point where I can write itself, and then add everything needed for a real Lisp. Then it wouldn't be 5 minutes anymore though.


Ehm? Where's the Lisp?

This is just Python syntax in S-expressions.


That is all it is indeed. So what is your definition of Lisp?

Wikipedia: Lisp or LISP is a family of computer programming languages with a long history and a distinctive, fully parenthesized syntax.


More from Wikipedia (which this version doesn't have):

The name LISP derives from "LISt Processing". Linked lists are one of Lisp languages' major data structures, and Lisp source code is itself made up of lists. As a result, Lisp programs can manipulate source code as a data structure, giving rise to the macro systems that allow programmers to create new syntax or even new domain-specific programming languages embedded in Lisp.

It also lists the following under "Syntax and semantics":

    Symbolic expressions           — Check
    Lists                          — Check
    Operators                      — Check
    Lambda expressions             — Check
    Atoms                          — Check
    Conses and lists               — Nope (not linked lists)
    S-expressions represent lists  — Nope
    List-processing procedures     — Check
    Shared structure               — Nope (not linked lists)
    Self-evaluating forms and quoting — Nope
    Scope and closure              — Kinda
    List structure of program code — Nope
    Evaluation and the Read-Eval-Print Loop — Nope
    Control structures             — Nope
The biggest difference which doesn't really make this a Lisp is probably that the code isn't a list, it's just a series of yield expressions. You can't really parse it as a list or manipulate it as a list. It's also missing cons/car/cdr which is sort-of the building block of Lisp languages!


Okay, point taken. Except the yield statements return plain tuples, so in fact it /is/ code as data(I just execute it as Python though). You can also have quoting by leaving of the yield, which will make it a plain old tuple.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: