How to debug an eval...

Started by hartrock, September 12, 2015, 02:13:07 AM

Previous topic - Next topic

hartrock

There is:

> (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:

> (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:

> (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.