Subject: Re: Tracing local functions (or 'labels 'flet) with CMUCL
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 08 Sep 2003 06:40:04 -0500
Newsgroups: comp.lang.lisp
Message-ID: <202dnVPo-8YJ98GiXTWc-w@speakeasy.net>
Eric Marsden  <emarsden@laas.fr> wrote:
+---------------
| Damien Kick <dkick1@email.mot.com> writes:
| dk> Would someone be able to give an example of doing something useful
| dk> with the :FUNCTION option to CMUCL's TRACE?  
| 
| TRACE is a macro; the argument to the :FUNCTION option is evaluated.
+---------------

Hmmm... One learns something every day. Let's see here...

	appsrv> (third *http-servers*)

	#S(HTTP-SERVER :SCHEME "http" :HOST "fast.rpw3.org"
	               :PORT 80 :DOC-ROOT "/usr/local/www/data")
	appsrv> (uri-handler-function
		  (find-uri-handler "/foo.lhp" (third *http-servers*)))

	#<Closure Over ORG.RPW3.CGI.LHP::CACHED-LHP-PAGE-FUNC {4853FB51}>

[Note: This is an anonymous function created earlier when the
"foo.lhp" page was demand-loaded.]

	appsrv> (trace :function *)

	(#<Closure Over ORG.RPW3.CGI.LHP::CACHED-LHP-PAGE-FUNC {4853FB51}>)
	appsrv> 

And at this point, hit the "Reload" button on the browser, and...

	; Sep  8 03:25:42.56 cgi-sock[14]: GET "/"
	  0: (ORG.RPW3.CGI.LHP::CACHED-LHP-PAGE-FUNC
	      #S(HTTP-REQUEST
		   :KIND :CGI-SOCK
		   :STREAM #<Stream for descriptor 15>
		   :CGI-ENV (# # # # # ...)
		   :BINDINGS NIL
		   :SELF "/foo.lhp"
		   ...))
	  0: #<Closure Over Function ORG.RPW3.CGI.LHP::CACHED-LHP-PAGE-FUNC
	       {4853FB51}> returned

Wow, neat! Didn't know you could do that. Thanks, Eric!


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607