Quick, Easy Question (I promise)

30 views
Skip to first unread message

Sphaerica

unread,
Jan 3, 2012, 10:38:51 AM1/3/12
to Skulpt
Skulpt does not appear to entirely "reset" between executions. If I
have a program that is being imported using my version of Sk.read() --
that is, one that "reads" the import from a javascript variable or
cookie -- if I then change that imported program and then load and run
the importing program, it still sees the old import code, not the new
code.

The following appears to be the relevant code from import.js, which is
probably intended to prevent the same module from being imported
twice:

// if leaf is already in sys.modules, early out
var prev = Sk.sysmodules.mp$subscript(modname);
if (prev !== undefined)
{
// if we're a dotted module, return the top level, otherwise
ourselves
if (modNameSplit.length > 1)
return Sk.sysmodules.mp$subscript(modNameSplit[0]);
else
return prev;
}

My question is: what is the best/right way to reset Sk.sysmodules? Or
can I simply dodge this, either all the time, or simply for programs
that are imported from local memory (rather than builtins)?

Sphaerica

unread,
Jan 7, 2012, 7:03:31 PM1/7/12
to Skulpt
I took care of this by adding:


Sk.sysmodules = new Sk.builtin.dict([]);
Sk.realsyspath = undefined;

to importMainWithBody() in import.js.

I'm unsure if it should also be added to importMain(), but since I'm
only invoking importMainWithBody(), that's working for me.
Reply all
Reply to author
Forward
0 new messages