srinivas@ncst.ernet.in (Srinivas Palthepu) (04/25/91)
I had a strange problem ith KCL. The STEPper in the KCL assumes always the top-level environment irrespective of whether you call it from top-level prompt or within a function. For example, the follwoing expression at lip prompt gave me an error. >(let ((a-number 10)) (step (+ a-number 10))) Error: The variable A-NUMBER is unbound. Error singalled by SYSTEM::STEPPER. .. .. > This means I can not call stepper other than from top-level. For example If I want to selectively stepp only particualr code and execute rest of the program normally, I can not do in KCL. Is it a bugg in KCL? -srini (srinivas@ncst.ernet.in)
jeff@aiai.ed.ac.uk (Jeff Dalton) (05/01/91)
In article <1377@shakti.ncst.ernet.in> srinivas@ncst.ernet.in (Srinivas Palthepu) writes: > >I had a strange problem ith KCL. The STEPper in the KCL assumes always >the top-level environment irrespective of whether you call it from >top-level prompt or within a function. For example, the follwoing >expression at lip prompt gave me an error. > >>(let ((a-number 10)) > (step (+ a-number 10))) > >Error: The variable A-NUMBER is unbound. >Error singalled by SYSTEM::STEPPER. > >This means I can not call stepper other than from top-level. >For example If I want to selectively stepp only particualr code >and execute rest of the program normally, I can not do in KCL. > >Is it a bugg in KCL? No. X3J13 voted to 'clarify" that step evaluates its argument in the current lexical environment. I would call this a change rather than a clarification. However, the following macro seems to work. ---------------------------------------------------------------------- ;;; New step macro (in-package :system) (defvar *step-print-level* 4 "The stepper binds *print-level* to this value.") (defvar *step-print-length* 5 "The stepper binds *print-length* to this value.") (defmacro step (form) `(let* ((*old-print-level* *print-level*) (*old-print-length* *print-length*) (*print-level* *step-print-level*) (*print-length* *step-print-length*)) (read-line) ;s.b. clear-input? (format *debug-io* "Type ? and a newline for help.~%") (setq *step-quit* nil) (let ((*evalhook* #'stepper)) ,form))) ---------------------------------------------------------------------- Jeff Dalton, JANET: J.Dalton@uk.ac.ed AI Applications Institute, ARPA: J.Dalton%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton