2009-08-05

lisp program = data ???

On Aug 4, 3:07 pm, Jimmy Miller wrote:
> I hope no one will perceive this post as an attempt at trolling.
>
> I have known for a long time that part of the power of Lisp is that
> Lisp code is represented in list form, and lists are one of the data
> structures in Lisp; therefore, code and data are the same thing. My
> question is, cannot a similar statement be made about many other
> languages with an eval function? In Python, for example, the eval
> function takes a string as an argument, and Python source code is
> represented as a string, so does Python also have the property that
> code and data are equivalent?
>
> I came across a quote by Paul Graham that seems to dismiss this idea:
>
> >Lisp code is made out of Lisp data objects. And not in the trivial sense that the source files contain characters, >and strings are one of the data types supported by the language. Lisp code, after it's read by the parser, is >made of data structures that you can traverse.
>
> I don't understand why the case of characters and strings is
> "trivial". Lisp source code can be thought of as being represented by
> a list, and a list is a Lisp data structure, so code = data in Lisp;
> but replace "list" with "string" and Lisp with "any language whose
> eval function takes a string", and suddenly you don't have a true
> statement anymore?
>
> I would appreciate it if someone could explain what sets Lisp apart
> from every other language with access to eval; after all, many of
> those languages are quite good at manipulating strings, and could
> conceivably perform complex manipulations on source code that is to be
> evaluated at a later point, just as Lisp is known for its list
> processing.
>
> If the answer lies in Paul's last remark about the parser, I would
> appreciate an example of a code manipulation that is possible in Lisp,
> but not possible in a language like Python or Ruby. If the answer
> lies solely in a Lisp macro's ability to manipulate code at compile
> time, then I fail to see what this fact has to do with code/data
> equivalence in a larger sense.
>
> Thanks in advance.

«
In lisp communities, it is widely recognized that lisp's regular syntax has the property that “code is data; data is code”. However, what does that mean exactly is usually not clearly understood in the lisp community. Here is its defining characteristics:

A regular nested syntax, makes it possible to do source code transformations trivially with a lexical scan.
»

to fully appreciate this single sentence summary, see:

• Fundamental Problems of Lisp
http://xahlee.org/UnixResource_dir/writ/lisp_problems.html

Xah
∑ http://xahlee.org/

No comments:

Post a Comment