[plt-scheme] Re: module constants and tracing

From: John Lawrence Aspden (news at aspden.com)
Date: Thu Sep 25 15:14:01 EDT 2008

Hi, thanks for the tip, but actually one of the things I want to learn is
all the extra plt stuff. For instance I'm currently splitting my evaluator
into modules and putting contracts everywhere. Converting the SICP programs
to use mutable pairs is not difficult, although actually surprisingly
instructive.... 

It would seem odd to learn an old/(obsolete?) version of what seems to be a
thoroughly good tool with lots of nice libraries.

Is there some special reason why the module 'constants' can't be mutable? If
I put set! or trace statements for each function in the code itself so that
the compiler stops assuming they're constants then everything seems to
work.

If there's no way to do it from the IDE, can I hack DrScheme itself? I
compiled it from source. Is there a place where the compiler is invoked and
a command line can be changed?

Apologies if this has been covered before. I did do a considerable amount of
reading and experimentation before posting. Is there something I should be
googling for?

It seems odd that a useful feature for interactive development is disabled
in the IDE (only). Am I supposed to be using emacs/mzscheme instead? Surely
something like trace has value for student programmers too?

Cheers, John.



Chongkai Zhu wrote:

> 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.
>>
>>
>>
>>
>>
>>
>>
>>
>>   
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-- 
Contractor in Cambridge UK -- http://www.aspden.com



Posted on the users mailing list.