How to debug an eval...

For the Compleat Fan
Locked
hartrock
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm

How to debug an eval...

Post by hartrock »

There is:

Code: Select all

> (define (foo) (println "foo" (+ 1 2)))
(lambda () (println "foo" (+ 1 2)))
> (trace true) (foo)
true

-----

(define (foo )
  #(println "foo" (+ 1 2))#)


[-> 2 ] s|tep n|ext c|ont q|uit >
; but there also is:

Code: Select all

> (define (foo) (println "foo" (+ 1 2)))
(lambda () (println "foo" (+ 1 2)))
> (trace true) ((eval 'foo))
true
foo3
3
0 > 
How to go into debug mode for eval?
There is a solution:

Code: Select all

> (define (foo) (println "foo" (+ 1 2)))
(lambda () (println "foo" (+ 1 2)))
> (define (w aSym) (trace true) (set 't (eval aSym)) (t))
(lambda (aSym) (trace true) (set 't (eval aSym)) (t))
> (w 'foo)

-----

(define (t )
  #(println "foo" (+ 1 2))#)


[-> 3 ] s|tep n|ext c|ont q|uit > 
In addition it may be needed to store argument expressions of a func into temp vars, and calling it with them, instead of evaluating expressions in arg postions.

Locked