[plt-scheme] module constants and tracing
If you are using DrScheme for SICP, use the pretty big language.
Chongkai
John Lawrence Aspden wrote:
> Hi,
>
> Is there anyway to set (compile-enforce-module-constants #f) as the default
> for DrScheme? I'd like to be able to trace function calls without having to
> reload the program from scratch.
>
> I'm playing with the meta-circular evaluator from SICP, and wishing to be
> modern I've started the program with #lang scheme, and dealt with the
> mutable pairs issues. The program is in a file "bookevaluator.ss"
>
> I can run it by loading "bookevaluator.ss" into drscheme, and pressing the
> run button. Then in my interactions window I can type:
>
>
>> (me "hi")
>>
> "hi"
>
> (me calls the evaluator on an expression)
>
> It works fine, but if I want to trace functions, and I type:
> (require (lib "trace.ss"))
> (trace self-evaluating?)
>
> then I get the error:
>
> set!: cannot modify a constant: self-evaluating?
>
> I've found by trial and error that if I create a second
> file "interactiveevaluator.ss" that contains:
>
> (define (go) (eval '(begin
> (require scheme/enter)
> (require (lib "trace.ss"))
> (compile-enforce-module-constants #f)
> (load "bookevaluator.ss")
> (enter! "bookevaluator.ss"))))
>
> and then load that into a *different* window, and press the run button, and
> then type (go), then I end up with a REPL where tracing works, and I can
> say:
>
>
>> (me ((λ(a b)(* a b)) 1 2))
>>
> 2
>
>
>> (trace apply-primitive-procedure)
>> (me ((λ(a b)(* a b)) 1 2))
>>
> |(apply-primitive-procedure (primitive #<procedure:*>) (1 2))
> |2
> 2
>
> But it would be nice to be able to do this in my original window. Nothing I
> try will make this happen at all. Am I missing something simple to get this
> to work? I'm using 4.1.0.3-svn11sep2008 [3m].
>
> Cheers, John.
>
>
>
>
>
>
>
>
>