5

From Steve Yegge's "Lisp is Not an Acceptable Lisp":

 Lisp has a little syntax, and it shows up occasionally as, for instance, '(foo)
 being expanded as (quote foo), usually when you least expect it.

What is he talking about with '(foo) being expanded into (quote foo) in some situations? (As opposed, I would imagine, to (quote (foo))).

4 Answers 4

7

I don't know. I cannot think of any situation where '(foo) would be turned into (quote foo) since it's actually the same as (quote (foo)) (the ' symbol is typically a reader macro that reads the next s-exp and returns it surrounded by a call to the quote special form).

2

'(foo) is not "expanded" into (quote foo). The two forms are precisely the same; the lisp reader READS '(foo) as (quote foo).

To think they are somehow different is to completely misunderstand how lisp reads forms internally.

1
  • 12
    No, the lisp reader reads 'foo as (quote foo) and '(foo) as (quote (foo)).
    – Vatine
    Commented Oct 29, 2012 at 14:36
2

In PicoLisp, '(foo) is equivalent to (quote foo) and 'foo is equivalent to (quote . foo).

I didn't understand that paragraph either. It's conceivable that Yegge was referring to PicoLisp (in the context of porting between Lisp dialects), or he could have been referring to a bug or corner case in a CL or Scheme implementation (though none that I am aware of.)

1
  • 1
    I suspect he just happened to typo a bit.
    – Vatine
    Commented Nov 2, 2012 at 14:10
1

That is precisely backwards. The surprising situation is that you have some data like:

(the (quick brown (quote jumped) over) the lazy symbol)

This data is not code; it's just some symbols. But when you print it, the Lisp system turns (quote jumped) into 'jumped which, to it, means exactly the same thing. To you, it might be irksome because that notation is inapplicable in your data.

The ANSI Common Lisp fix for this is to use packages. The reason (quote jumped) turned into 'jumped is that we're in a package in which the quote symbol that is visible is the one imported/used from the common-lisp package: i.e. the symbol common-lisp:quote. We could use ourpackage for the data, in which ourpackage:quote has nothing to do with common-lisp:quote; the Lisp printer will leave it alone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.