On 2007-05-24, ··········@gmail.com <··········@gmail.com> wrote:
> Why does (list 'quote 123) evaluate to '123 and not (quote 123) ?
>
>> (list 'quote 123)
> '123
>
>> (list 'quote 123 456)
> (QUOTE 123 456)
>
>> (list 456 'quote 123)
> (456 QUOTE 123)
Because 'X is actually syntactic sugar for (quote X); the two expressions are
the same. The pretty-printer is taking the expression (quote X) and
"re-sugaring" it before displaying it; it will only do so with things that
could actually have been generated by the 'X abbreviation, which means lists of
length two whose first element is the symbol QUOTE. Other things it will leave
alone (as you see with your longer lists, or lists not beginning with QUOTE.)
The important point is that it _does_ evaluate to (quote 123) -- the
difference is purely one of display, and is actually an illusion.
-- Glenn Willen
··········@gmail.com writes:
> Why does (list 'quote 123) evaluate to '123 and not (quote 123) ?
>
> > (list 'quote 123)
> '123
CL-USER> (write (list 'quote 123) :pretty nil)
(QUOTE 123)
'123
It is the pretty printer that is recognising
(quote . (123 . nil)) and printing it '123
Turn off the pretty printer and
(quote . (123 . nil)) is printed (quote 123)
Alan Crowe
Edinburgh
Scotland
On May 24, 11:37 pm, Alan Crowe <····@cawtech.freeserve.co.uk> wrote:
> ··········@gmail.com writes:
> > Why does (list 'quote 123) evaluate to '123 and not (quote 123) ?
>
> > > (list 'quote 123)
> > '123
>
> CL-USER> (write (list 'quote 123) :pretty nil)
>
> (QUOTE 123)
>
> '123
>
> It is the pretty printer that is recognising
> (quote . (123 . nil)) and printing it '123
>
> Turn off the pretty printer and
> (quote . (123 . nil)) is printed (quote 123)
Thanks.. that answers it for me.
Although I found that CLISP still prints (write (list 'quote
123) :pretty nil) as '123, while SBCL properly prints (QOUTE 123). Why
is CLISP showing such behaviour?
--
Vaibhav
··········@gmail.com wrote:
> Although I found that CLISP still prints (write (list 'quote
> 123) :pretty nil) as '123, while SBCL properly prints (QOUTE 123). Why
> is CLISP showing such behaviour?
As stated in the other answers, both behaviours are semantically
equivalent. So it is up to the implementation to decide how to display it.
IIRC there was a discussion about which behaviour is better in this
group not too long ago.
Regards,
Christian