Using OpenMCL's stepper

Like commercial MCL, OpenMCL ordinarily compiles function definitions automatically. (This behavior is actually governed by the value of the variable CCL:*COMPILE-DEFINITIONS* at the time that the defining form is executed. That variable's value defaults to T; one has to ensure that the module named EVAL is loaded in order to successfully create an evaluated function.)

OpenMCL's stepper only knows how to step through evaluated functions. It's hard to think of another reason to create an evaluated function ...

If a function is defined in the null lexical environment and its lambda expression (as returned by the CL function FUNCTION-LAMBDA-EXPRESSION) is available, the stepper can create an evaluated function on the fly. Compiled functions retain their lambda expressions if the value of CCL:*SAVE-DEFINITIONS* is non-nil when they're defined. COMPILE-FILE binds CCL:*SAVE-DEFINITIONS* to the value of CCL:*FASL-SAVE-DEFINITIONS* during its execution.

For example ...


Welcome to OpenMCL Version (Beta: linux) 0.9!
? (defun fact (n)
    (if (zerop n)
      1
      (* n (fact (1- n)))))
FACT
? (step (fact 5))
(block nil (fact 5))
Step> :s
  (fact 5)
  Step> :s
  120
120
120
?
    

Well, that wasn't very interesting. Let's try again:


? (setq ccl:*save-definitions* t)
T
? (defun fact (n)
    (if (zerop n) 
      1
      (* n (fact (1- n)))))
FACT
(step (fact 2))
(block nil (fact 2))
Step> :s
  (fact 2)
  Step> :s
    (block fact (if (zerop n) 1 (* n (fact #))))
    Step> :s
      (if (zerop n) 1 (* n (fact (1- n))))
      Step> :s
        (zerop n)
        Step> :s
          n = 2
        nil
        (* n (fact (1- n)))
        Step> :go
2
? 
    

(OK, that's not exactly interesting either ...)

If a compiled function is defined in a non-null lexical environment, the stepper can't create an equivalent interpreted function; as mentioned above, it's necessary to define the entire lexical clozure with CCL:*COMPILE-DEFINITIONS* nil in order to step through the internal function.


Last modified: Fri Dec 7 07:17:09 PST 2001