[Openmcl-devel] tracing recursion with ccl

Ron Garret ron at flownet.com
Thu Jul 7 15:49:18 PDT 2016


This is a feature :-)

The CCL compiler is pretty smart about compiling self-calls to make them efficient.  One of the ways it does that is by bypassing the entry code that checks for things like that the correct number of arguments have been passed, and whether or not the function has been traced.

You can disable this by declaring the function to be “notinline”, i.e.:

(declaim (notinline trim-head))

rg

On Jul 7, 2016, at 3:01 PM, ◒ Simon Lucas ◒ <simon at spiral.co.uk> wrote:

> CCL's built-in trace does not seem to trace repeated calls to a recursive function call. Not in the way I expected.
> 
> Is this correct? I need to get a better idea what is going as I work through examples.  Do I need to write a version of Winston/Horn's our-trace?
> 
> 
> (defun trim-head (l n)
>  (cond ((zerop n) nil)
>        (t (cons (car l) (trim-head (cdr l) (- n 1))))))
> 
> ? (trace trim-head)
> NIL
> ? (trim-head '(a s d f g h j k l) 3)
> 0> Calling (TRIM-HEAD (A S D F G H J K L) 3) 
> <0 TRIM-HEAD returned (A S D)
> (A S D)
> ? 
> 
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list