____________________
Racket Users list:
http://lists.racket-lang.org/users
A simple tool you can use is the 'racket/trace' library:
http://docs.racket-lang.org/reference/debugging.html
It'll make the execution of a function visible to you. You have to
explicitly trace the function you want to watch.
---
There's also an "errortrace" module that can help produce stack traces:
http://docs.racket-lang.org/errortrace/using-errortrace.html
You need to do a little work to hook it into your program. For an
example, see the very top startup script of Eric Hanchrow's rudybot:
https://github.com/offby1/rudybot/blob/master/freenode-main.rkt
where you'll see that it has the line:
exec racket -l errortrace --require "$0" --main -- ${1+"$@"}
at the top: that's one way to hook errortrace in.
I have tried trace library but I have a problem.
If I put my definitions in the interactive window, everything is fine.
But if I put the definitions in the definition window and then I try to
trace them, I get error "set!: cannot modify a constant: ".
Why?
Let me assume you're doing something like this, that in Definitions,
you have something like this:
#lang racket
(require racket/trace)
(define (f x) (* x x))
and in Interactions, you're trying to use trace:
> (trace f)
and you see an error at this point:
set!: cannot modify a constant: ..
What's happening here is that the program in Definitions tries to
determine whether each definition is constant or not. It doesn't see
that anything is changing 'f' inside Definitions, so it freezes the
definition. Unfortunately, that means that you can't trace it.
Here's how to work around this: you can add the following right after
a definition, such as f:
#lang racket
(require racket/trace)
(define (f x) (* x x))
(set! f f)
The set! there is a no-op, but it effectively tells Racket not to
enforce the constantness of f. Then trace can be run on it from
Interactions.
Perhaps an easier approach is to just trace it inside the definitions:
#lang racket
(require racket/trace)
(define (f x) (* x x))
(trace f)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
[...]
> There's also an "errortrace" module that can help produce stack traces:
>
> http://docs.racket-lang.org/errortrace/using-errortrace.html
>
> You need to do a little work to hook it into your program. For an
> example, see the very top startup script of Eric Hanchrow's rudybot:
>
> https://github.com/offby1/rudybot/blob/master/freenode-main.rkt
>
> where you'll see that it has the line:
>
> exec racket -l errortrace --require "$0" --main -- ${1+"$@"}
>
> at the top: that's one way to hook errortrace in.
Just a note (since the OP mentioned he's using it): geiser already loads
errortrace in its REPLs, so using geiser is another way.
Cheers,
jao
--
Men can live without air a few minutes, without water for about two
weeks, without food for about two months - and without a new thought
for years on end.
-Kent Ruth
> A few minutes ago, Danny Yoo wrote:
>> Here's how to work around this: you can add the following right after
>> a definition, such as f:
>>
>> #lang racket
>> (require racket/trace)
>> (define (f x) (* x x))
>> (set! f f)
>>
>> The set! there is a no-op, but it effectively tells Racket not to
>> enforce the constantness of f. Then trace can be run on it from
>> Interactions.
>
> Perhaps an easier approach is to just trace it inside the definitions:
>
> #lang racket
> (require racket/trace)
> (define (f x) (* x x))
> (trace f)
Thanks.