Instantly share code, notes, and snippets.

Embed
What would you like to do?

In Lisp, we use brackets to determine where an expression starts and ends. This looks weird and adds a lot of cluttering brackets. Can we get rid of them?

Suggestion: Each form has an arity (which can be *); the parser uses left-to-right parsing to determine where an expression starts and finishes.

Let's assume + is a 2-form, and numerics are values (1-form):

+ 2 2     # => (+ 2 2)
+ 2 + 2 2 # => (+ 2 (+ 2 2))

define is a 2-form, as is fn:

define x 2                # => (define x 2)
define add fn (a b) + a b # => (define add (fn (a b) (+ a b)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment