[plt-scheme] Simple IDE questions: multi-file projects

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Tue Sep 9 08:22:52 EDT 2008

> On Sep 8, 2008, at 19:19 , Henk Boom wrote:
>
>> 2008/9/8 Eric Tanter <etanter at dcc.uchile.cl>:
>>>> The short answer is that modules may have macros and other things that
>>>> affect the compilation of those that require them, so cycles are just
>>>> disallowed.
>>>
>>> Ok I understand that. Would be nice if I could say (or even better, 
>>> if the
>>> system could figure out --fairly straightforward I guess) that a 
>>> module is a
>>> "plain standard definitions module" so that these issues don't show up.
>>>
>>>> You might try using units inside your files
>>>
>>> ok, will look at what this other kind of beast is...
>>>
>>>> (or just refactoring ...)
>>>
>>> I understand this idea, but does not always work. I have an 
>>> interpreter and
>>> a transport layer, I want them to be separate modules, but one needs 
>>> to call
>>> the other, and vice-versa. Can't help it. And I can imagine tons of 
>>> similar
>>> cases...
>>
>> You could try dynamic-require, which seems to work in my experience.

Eric Tanter wrote:
> Indeed, with dynamic-require I was able to have things work. Thanks a 
> lot!
>

I am not sure dynamic-require is the solution. I suspect the error messages
might not be as precise as they could be.

Here is one strategy that will break the cycle.

Introduce a module called config.ss:

#lang scheme
(provide current-interpreter current-transporter)
(define current-interpreter
           (make-parameter (lambda x (error "no current interpreter yet"))))
(define current-transporter
            (make-parameter (lambda x (error "no current transporter 
yet"))))


This module is to be required in both the interpreter and the 
transporter module.
Now in the interpreter module, you need to set the current-interpreter 
like this:
    (current-interpreter my-interpreter)
at the bottom of the source file.

In the transporter, you can now call the interpreter like this:

   ((current-interpreter) the-source-of-program an-environment 
other-args ...)

Another strategy is to add a parameter to the interpreter, so that it
besides the program and environment also takes a transporter as input.

-- 
Jens Axel Søgaard



Posted on the users mailing list.