Hacker News new | past | comments | ask | show | jobs | submit login
Homoiconicity isn't the point (calculist.org)
1 point by luu on Feb 16, 2014 | hide | past | favorite | 1 comment



S-Expressions are a syntax for data. READ reads an s-expression and creates a data representation: lists, symbols, numbers, strings, vectors, characters, ...

This data then can also be used to encode programs. There are two ways to create these programs: read them and construct them.

The main execution entry point in Lisp is EVAL, the evaluator. It takes a Lisp data structure as source - not strings, not streams, not a data structure created by a parser for the language Lisp.

Thus the point of Lisp is that it uses Lisp data structures as representation of source code. This source code can be read, can be constructed and can be printed.

    CL-USER 15 > (setf expression (list '+ 3 4))
    (+ 3 4)

    CL-USER 16 > (setf expression (append expression '(5 6)))
    (+ 3 4 5 6)

    CL-USER 17 > (setf expression (list '* expression expression 5))
    (* (+ 3 4 5 6) (+ 3 4 5 6) 5)

    CL-USER 18 > (eval expression)
    1620
The evaluator was first in Lisp. Macros came a few years later.

The initial idea was the evaluator and programming with symbolic expressions. Using Lisp itself to transform symbolic expressions as used in macros, is just one application of these ideas. These expressions can not only represent Lisp code, but also logic expressions on mathematical formulas. Thus the idea of symbolic expressions of Lisp code made macro expansion natural - similar as it was used to for example to computer algebra algorithms: integration and differentiation of mathematical expressions, represented as Lisp data.




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

Search: