Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.scheme Subject: Re: function tracing in Scheme Message-ID: Date: 26 Apr 91 19:17:41 GMT References: Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Distribution: comp.lang.scheme Organization: M.I.T. Artificial Intelligence Lab. Lines: 50 In-reply-to: jaffer@zurich.ai.mit.edu's message of 26 Apr 91 16:02:38 GMT In article jaffer@zurich.ai.mit.edu (Aubrey Jaffer) writes: Here is code for tracing functions which should work in any scheme. If you have macros on you system you can add some syntactic sugar and finish the job. And yes, it can trace itself. And no, it doesn't get screwed up if you trace functions it uses. ;;;; Utility functions for debugging in Scheme. ;;; to TRACE type ;;; (set! (tracef )) or ;;; (set! (tracef ')) or ;;; (define (tracef )) or ;;; (define (tracef ')) ;;; to UNTRACE type ;;; (set! (untracef )) [code for trace and untrace omitted] This is all well and good, but only useful for procedures that are referenced by name (and it only traces them where they are referenced by that name, and you lose eq-ness for traced procedures). You need some hackery in the interpreter and/or compiler to make tracing work for arbitrary procedures. ;;; TRACEF REALLY NEEDS A `PRINT ANYTHING ON ONE LINE' ROUTINE. DOES ;;; SOMEONE CARE TO WRITE IT? Unless I misunderstand what you mean I think that the following will do it. (define (display-anything-on-one-line . things) (if (not (null? things)) (let loop ((things things)) (if (null? things) (newline) (begin (display (car things)) (loop (cdr things))))))) -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu