Search code examples
lispelisp

the list inside a list of lisp tutorial


I am reading Programming in Emacs Lisp

Here is another list, this time with a list inside of it:

     '(this list has (a list inside of it))

I am confused with the nested list, why it has not a prefix quoting as

 '(this list has  '(a list inside of it))

if not has a prefix `, why it not parse the a as a function?


Solution

  • 's-expression is an abbreviation for (quote s-expression): anything inside the s-expression is considered a datum and it is not evaluated.

    So,

    '(this list has (a list inside of it))
    

    is an abbreviation of:

    (quote (this list has (a list inside of it)))
    

    that contains the following list:

    (this list has (a list inside of it))
    

    which is the value of the entire quote form since it is not evaluated.

    It is easy to verify this by writing:

    '(this list has '(a list inside of it))
    

    This, if evaluated, will produce as value the following list:

    (this list has (quote (a list inside of it)))