Lisp refactoring puzzle

Teemu Likonen tlikonen at iki.fi
Wed Jul 13 11:25:00 EDT 2011


* 2011-07-13T10:34:41-04:00 * Terry Reedy wrote:

> On 7/13/2011 4:29 AM, Teemu Likonen wrote:
>> Please don't forget that the whole point of Lisps' (f x) syntax is
>> that code is also Lisp data.
>
> Thank you for clarifying that. Some Lispers appear to promote the
> simple, uniform syntax' as a end in itself (making code=data a side
> effect) rather than as a means to accomplish a deeper end.

Perhaps, yes. We can't really speak of Lisp's syntax in the same sense
as syntax in other languages.

>>      CL-USER>  (let ((lisp (cons 'programmable nil)))
>>                  (setf (rest lisp) lisp))
>
> This much looks like Lisp
>
>>      #1=(PROGRAMMABLE . #1#)
>
> This must be some of the new-fangled Common LIsp stuff I never learned
> ;=).

It's a way for the Lisp printer to show circular structures. In this
case it shows a cons cell. Its first part is the symbol PROGRAMMABLE and
the second part is a pointer back to the cons cell itself. So, it's a
kind of infinite linked list with the same item PROGRAMMABLE all the
time. With Lisp printer settings

    (setf *print-circle* nil
          *print-length* 5)

the same thing would be printed this way:

    (PROGRAMMABLE PROGRAMMABLE PROGRAMMABLE PROGRAMMABLE PROGRAMMABLE ...)



More information about the Python-list mailing list