1

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#))
noein
  • 411
  • 2
  • 10
  • what does `show-arglist` return? Are you sure it's properly defined in the right package? I tried the code on Linux and it works just fine – Vsevolod Dyomkin Mar 14 '21 at 15:22
  • You are right. I had to write ccl:arglist. Unfortunately, I am still unfamiliar with the modules. – noein Mar 14 '21 at 17:04
  • 1
    You should be looking at [`dtrace.mcl`](https://www.cs.cmu.edu/%7Edst/Lisp/dtrace/dtrace.mcl), since Clozure Common Lisp grew from Macintosh Common Lisp. – ad absurdum Mar 14 '21 at 19:41
  • See also printv: https://github.com/danlentz/printv – Ehvince Mar 14 '21 at 22:59
  • @adabsurdum dtrace.mcl works after replacing *special-form-p* with *special-operator-p*. However it has the same problems reported in update2 – noein Mar 15 '21 at 10:22
  • 1
    That is controlled by `*print-circle*`. You'll have to wrap `(let ((*print-circle* nil)) ...)` around the code that performs the actual printing. Probably, in `display-one-arg` – Vsevolod Dyomkin Mar 15 '21 at 21:41

0 Answers0