[plt-dev] order of module requires

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Apr 22 09:45:10 EDT 2009

It is unwise to rely on the (implicit) ordering of modules. When you
just have the simple setup you suggest below, that all seems
reasonable, but do the "only instantiate once" behavior of module
requires, some other module might come along and require
module-sequence2.ss from some faraway place and break things.

Better to just put your initialization code into thunks and then have
a main thunk somewhere that calls all of the initialization code in
the right order.

Robby

On Wed, Apr 22, 2009 at 8:42 AM, Jos Koot <jos.koot at telefonica.net> wrote:
> It appears that modules are not run in the same order as they are required.
> This can give trouble when modules have side effects, for instance one
> module writing a file and the other one reading that file. As an example:
>
> File module-sequence1.ss
> #lang scheme
> (printf "module 1~n")
>
> File module-sequence2.ss
> #lang scheme
> (printf "module 2~n")
>
> File module-sequence12.ss
> #lang scheme
> (require "module-sequence1.ss")
> (require "module-sequence2.ss")
> ;Displays:
> ;module 2
> ;module 1
>
> Is it possible to run modules in the order they are required?
> (may be by inserting 'inverse' somewhere in #%module-begin?)
> Jos
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-dev
>
>


Posted on the dev mailing list.