slang-users mailing list

[2019 Date Index] [2019 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] How to unload a module


Bernd Eggink <bernd.eggink@xxxxxxxxxx> wrote:
> Is it possible to unload or re-load a module? When testing a source in 
> an slsh session, changes made from outside (e.g. in a different window) 
> won't take effect until the module is loaded again.
> Without the possibility to re-load the function, the only way to achieve 
> that is to kill slsh and start it again, which is cumbersome and might 
> involve a lot of typing.

If you are talking about slang interpreted code, then yes, just reload
the file containing the code.  If you are referring to a C compiled
module that gets dynamically linked in at runtime, then the answer is
no.

Keep in mind that there are different ways to load a file into the
interpreter.  If you want to load the same file more than once, use
the evalfile function:

   slsh> !echo 'print(10);' > foo.sl
   slsh> () = evalfile("foo.sl");
   10
   slsh> !echo 'print(20);' > foo.sl
   slsh> .load ./foo.sl
   20
   slsh> !echo 'print(30);' > foo.sl
   slsh> require ("./foo.sl");
   30
   slsh> require ("./foo.sl");
   slsh> .load ./foo.sl
   30

In the above, if a command line begins with a `!' character, the rest
of the command will be interpreted as a shell command.  The .load
command is a shortcut for the evalfile function.  Note that the second
invocation of the `require' function did not re-load the file because
it was already loaded.

--John
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.


[2019 date index] [2019 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]