It's all well and good, but I remember in my gdb days where I could step through the code and examine all of the variables as I went through each function. Maybe I missed it in the above tutorial, but how could I do this?
> It's all well and good, but I remember in my gdb days where I could
> step through the code and examine all of the variables as I went
> through each function. Maybe I missed it in the above tutorial, but
> how could I do this?
There is "step" in the standard. I use sbcl and not clisp, but just as
an example:
* (declaim (optimize (debug 3) (speed 0)))
* (defun fact (x) (if (= x 1) 1 (* x (fact (1- x)))))
1] step
; Evaluating call:
; (- X 1)
; With unknown arguments
0] next
; Evaluating call:
; (FACT (1- X))
; With arguments:
; 4
1] list-locals
X = 5
Check the clisp documentation for information about how to do it
there...
-- Ben
-- Benjamin R Kreuter
UVA Computer Science
brk...@virginia.edu
KK4FJZ
--
"If large numbers of people are interested in freedom of speech, there
will be freedom of speech, even if the law forbids it; if public
opinion is sluggish, inconvenient minorities will be persecuted, even
if laws exist to protect them." - George Orwell
Yves S. Garret <yoursurrogate...@gmail.com> wrote:
> It's all well and good, but I remember in my gdb days where I
> could step through the code and examine all of the variables as I
> went through each function. Maybe I missed it in the above tutorial,
> but how could I do this?
Never underestimate the value of a few strategic PRINT expressions.
While a debugger is certainly useful, I rarely find myself in a
position where I actually need one.
-- Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
>> It's all well and good, but I remember in my gdb days where I could
>> step through the code and examine all of the variables as I went
>> through each function. Maybe I missed it in the above tutorial, but
>> how could I do this?
> There is "step" in the standard. I use sbcl and not clisp, but just as
> an example:
cl-user> (ql:quickload :com.informatimago.common-lisp.lisp.stepper)
To load "com.informatimago.common-lisp.lisp.stepper":
Load 1 ASDF system:
com.informatimago.common-lisp.lisp.stepper
; Loading "com.informatimago.common-lisp.lisp.stepper"
[package com.informatimago.common-lisp.lisp.stepper.internal]
[package com.informatimago.common-lisp.lisp.stepper].
......
(:com.informatimago.common-lisp.lisp.stepper)
cl-user> (defpackage :test (:use :cl-stepper))
#<package "TEST">
cl-user> (in-package :test)
#<package "TEST">
test> (defun fact (x) (if (= x 1) 1 (* x (fact (1- x)))))
fact
test> (step (fact 5))
(Will evaluate (fact 5)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact 5)
(Will evaluate 5
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 5))
(Entering function fact
(Bind x to 5)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (= x 1)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
(Will evaluate 1
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 1))
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (* x (fact (1- x)))
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
(Will evaluate (fact (1- x))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact (1- x))
(Will evaluate (1- x)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (1- x)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 5))
Evaluation of (1- x) returned one result ==> 4)
(Entering function fact
(Bind x to 4)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (= x 1)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
(Will evaluate 1
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(--> 1))
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (* x (fact (1- x)))
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
(Will evaluate (fact (1- x))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (fact (1- x))
(Will evaluate (1- x)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
Will evaluate (1- x)
(Will evaluate x
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(x ==> 4))
Evaluation of (1- x) returned one result ==> 3)
(Entering function fact
(Bind x to 3)
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?s
(Will evaluate (if (= x 1) 1 (* x (fact #)))
Step Into (s, si, RET), Step over (so), Trace (t), Function (f), Run (r), Debugger (d), Abort (a, q)?t
Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 3)
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
(x ==> 3)
(Will evaluate (fact (1- x))
(Will evaluate (1- x)
(x ==> 3)
Evaluation of (1- x) returned one result ==> 2)
(Entering function fact
(Bind x to 2)
(Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 2)
Evaluation of (= x 1) returned one result ==> nil)
(Will evaluate (* x (fact (1- x)))
(x ==> 2)
(Will evaluate (fact (1- x))
(Will evaluate (1- x)
(x ==> 2)
Evaluation of (1- x) returned one result ==> 1)
(Entering function fact
(Bind x to 1)
(Will evaluate (if (= x 1) 1 (* x (fact #)))
(Will evaluate (= x 1)
(x ==> 1)
Evaluation of (= x 1) returned one result ==> t)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 1)
Exiting function fact returned one result ==> 1)
Evaluation of (fact (1- x)) returned one result ==> 1)
Evaluation of (* x (fact (1- x))) returned one result ==> 2)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 2)
Exiting function fact returned one result ==> 2)
Evaluation of (fact (1- x)) returned one result ==> 2)
Evaluation of (* x (fact (1- x))) returned one result ==> 6)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 6)
Exiting function fact returned one result ==> 6)
Evaluation of (fact (1- x)) returned one result ==> 6)
Evaluation of (* x (fact (1- x))) returned one result ==> 24)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 24)
Exiting function fact returned one result ==> 24)
Evaluation of (fact (1- x)) returned one result ==> 24)
Evaluation of (* x (fact (1- x))) returned one result ==> 120)
Evaluation of (if (= x 1) 1 (* x (fact #))) returned one result ==> 120)
Exiting function fact returned one result ==> 120)
Evaluation of (fact 5) returned one result ==> 120)
120
test>
> Now, how can I get common lisp to "see" this library so that I can use it?
Now, since I may commit new features or bug corrections at any time, and
since quicklisp only updates once a month, you may want to clone the
repository directly until next month. In that case, do it in
~/quicklisp/local-projects and keep using the quickload form above.
*** - READ from #<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM> #<IO TERMINAL-STREAM>>: there is no package with name "QL"
The following restarts are available:
ABORT :R1 Abort main loop
Break 1 [2]>
> *** - READ from #<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM> #<IO TERMINAL-STREAM>>: there is no package with name "QL"
> The following restarts are available:
> ABORT :R1 Abort main loop
> Break 1 [2]>
> A bad day in () is better than a good day in {}.
Hi informatimago, I tried what you showed me to do and it worked wonderfully. There is one problem though, after I finished stepping through the program, I was stuck at this:
test>
I couldn't do (quit) or use my declared functions in .clisprc.lisp (located in my home directory), how do I get out of this state?
"Yves S. Garret" <yoursurrogate...@gmail.com> writes:
> Hi informatimago, I tried what you showed me to do and it worked
> wonderfully. There is one problem though, after I finished stepping
> through the program, I was stuck at this:
> test>
> I couldn't do (quit) or use my declared functions in .clisprc.lisp
> (located in my home directory), how do I get out of this state?
The prompt in slime gives the name (or part of the name) of the current
package.
In clisp, the COMMON-LISP-USER package uses the EXT package which
exports a QUIT function.
So you have the choice between changing the current package to a package
where "quit" would be read as the symbol EXT:QUIT, or calling that
directly:
> "Yves S. Garret" <yoursurrogate...@gmail.com> writes:
>> Hi informatimago, I tried what you showed me to do and it worked
>> wonderfully. There is one problem though, after I finished stepping
>> through the program, I was stuck at this:
>> test>
>> I couldn't do (quit) or use my declared functions in .clisprc.lisp
>> (located in my home directory), how do I get out of this state?
> The prompt in slime gives the name (or part of the name) of the current
> package.
> In clisp, the COMMON-LISP-USER package uses the EXT package which
> exports a QUIT function.
> So you have the choice between changing the current package to a package
> where "quit" would be read as the symbol EXT:QUIT, or calling that
> directly:
> test> (ext:quit)
> or:
> test> (in-package :cl-user)
> cl-user> (quit)
or of couse, you can use the package where the wanted symbols are, or
import them: