Dtrace from Touretzky

199 Views Asked by At

I am trying to learn lisp with the book "Common LISP a Gentle Introduction to Symbolic Computation" written by Touretzky. There is a utility in the book, Dtrace(I use dtrace.generic). Example of using dtrace:

(defun add-to-end (x y)
  (append x (list y)))
(defun repeat-first (phrase)
  (add-to-end phrase (first phrase)))
> (dtrace add-to-end repeat-first)
(ADD-TO-END REPEAT-FIRST)
> (repeat-first ’(for whom the bell tolls))
----Enter REPEAT-FIRST
|     PHRASE = (FOR WHOM THE BELL TOLLS)
|   ----Enter ADD-TO-END
|   |     X = (FOR WHOM THE BELL TOLLS)
|   |     Y = FOR
|    \--ADD-TO-END returned
|          (FOR WHOM THE BELL TOLLS FOR)
 \--REPEAT-FIRST returned
      (FOR WHOM THE BELL TOLLS FOR)
(FOR WHOM THE BELL TOLLS FOR)

Unfortunately in Clozure (on Win7) the result is:

? (repeat-first '(for whom the bell tolls))
----Enter REPEAT-FIRST
|     Arg-1 = (FOR WHOM THE BELL TOLLS)
|   ----Enter ADD-TO-END
|   |     Arg-1 = (FOR WHOM THE BELL TOLLS)
|   |     Arg-2 = FOR
|    \--ADD-TO-END returned (FOR WHOM THE BELL TOLLS FOR)
 \--REPEAT-FIRST returned (FOR WHOM THE BELL TOLLS FOR)
(FOR WHOM THE BELL TOLLS FOR)

Function argument names are lost. It should depend on the fetch-arglist function. Based on this answer, I wrote fetch-arglist as:

(defun fetch-arglist (x) (arglist x))

In fact:

? (arglist #'add-to-end)
(X Y)
:ANALYSIS

Unfortunately, the result is the same. Is there a way, in Clozure, to make the argument names of functions appear in dtrace?

Update: Solution is (in dtrace.generic):

(defun fetch-arglist (x) (ccl:arglist x))

Update2: dtrace prints strange results as:

((CCC (? AAA . #1=(0)) (? BBB . #1#)))

While trace of Clozure prints correctly:

 ((CCC (? AAA 0) (? BBB 0)))

Update3(and hopefully last): Solution due to Vsevolod Dyomkin:

(defparameter *dtrace-print-circle* nil)

*print-circle* shows common substructure:

CL-USER> (setf *print-circle* t)
T

CL-USER> (let ((l '((a b c) (d e f))))
           (list l (copy-list l)))
;=> ((#1=(A B C) #2=(D E F)) (#1# #2#))
0

There are 0 best solutions below