Cling reload/unload doesn't work?

Hi I was just wondering if there was a way to reload a file in cling. .L <same_file> seems to complain that the definitions are already there. (as oposed to cint reloading) are there any plans to fixing this functionality in cling?

Hi,
Absolutely. This will come as part of ROOT 6.
Cheers,
Vassil

Awesome! will there be any shortcuts to reload modified files without specifying the filename?

Hi,
This is a nice idea. It should be possible to implement such a command. But let’s make the unloading work first and then we will see.
Cheers,
Vassil

cool. cling + reload functionality would = one of the most powerful programming tools I’ve ever used!

Hi,

Unloading/Reloading will be an awesome feature. I am interested in understanding how the implementation will work . For ex: What will happen to the object and its pointers which is pointing to the class which is unloaded ? Will it be dangling ? potential crashes ?
Once when it is unloaded and and same class is loaded again with some changes will these pointers point automatically to newly loaded class ?

Thanks,
Shailesh.

Hi Shailesh,

When unloading we will attempt to unload all the dependent libraries, however you can still end up in the situation you are describing (for example if what you unload if the implementation of a derived class and you are stored the pointer in a collection of base class pointer). In those situation, for better or worse, there is not much the unloading can do about leaving those pointer dangling (and being wrong if you reload a different definition of the derived class). Solving this would require to monitor and record (almost) every object allocation which would be an overkill (and thus a large performance penalty) in the general case.

Cheers,
Philippe.

in the case of all the dangling pointers and unsafe objects, will it be possible to reset the environment while still enjoying the priviledge of a reloaded source file? Y’know just a shallow reset?

Hi,

I am not sure what you mean. A ‘shallow reset’ seems to be pretty much what we already do (delete all the global object and function static and reload the definitions).

Cheers,
Philippe.

oh ok perfect, no that’s exactly what i meant :slight_smile:

Ok now I have another question sorry :frowning:
Upon the event of loading source files, might there be a way to customize a shell command before the load? for example, I use this tiny program to replace personally unique macros in my source files with valid c++ code. Sort of basically doing sed on the file to replace all x characters with y characters.
So might there be a way to customize a load call that runs that kind of shell command for you instead of processing my source files manually before loading them ? ( you know maybe like you can pass the filename parameter to a personal shell command )

HI,

That depends how you load/compile your script. In similar case I just use (#define MACRO correct_stuff) for interpreter function and -DMACRO=correct_stuff passed to the compiler and/or ACLiC to have the C++ preprocessor do the replacement at compile/interpret time rather than having to modify the source file.

Cheers,
Philippe.