API: scopes and curley braces

Hey Guys,

I’m trying to keep local contexts, to avoid unloading from the interpreter, but im not sure how to “officially” do it.

I want to do the equivilant to this. I know that process() is the wrong function to do, but I’m doing this for the sake of illustrating an example

cling::Interpreter inter();
inter.process("{")
inter.process(“int a,b,c;”);
inter.process(“a = 4; b =99; c=-4556”);
inter.process("}")

inter.process("{")
inter.process(“int a,b,c;”);
inter.process(“a = 4345; b =929; c=-44556”);
inter.process("}")

Right now, the ony way I can think of doing this “correctly”: is to record all of my calls to a string (with the curly braces starting and ending the string) then running process() on it. My worry however, is that the string what execute correctly (in case execute() and declare() need to be called seperately on the file…)

can somebody give me some advice for this?
Thanks

Hi,

We have just uploaded the support for multiple interpreters. You may want to give that a try - if you’re not time-critically spinning up new contexts. It should allow you to move the temporary contexts into a child interpreter, and discard that once done.

See the Interpreter constructor taking another Interpreter.

Cheers, Axel.

Thanks Axel,

I’m going to give this a shot. Any word when this feature will be moved into release?

Also a question: does the child interpreter inherit the parent’s state?
In otherwords, if I have a number of headers loaded into the parent, will a new child know about its parent’s headers?

Thanks again!

Hi,

Well - this is cling, not ROOT, and we haven’t had a cling release for a while. Are you asking for a cling release?

And yes, that’s the whole point: the child interpreter can ask the parent interpreter as soon as it doesn’t know something. The parent interpreter remains frozen (also to the extent that we currently do not allow the parent to be modified during the lifetime of the child).

Let me know what we can do to make this more accessible to you!

Cheers, Axel.

Thanks again for responding Axel,

I was asking about a ROOT release (especially since compiling and deployment of ROOT is just so much easier).

Im fine with the git snapshot, however for peace of mind prefer a release snapshot :slight_smile:
(for clarification, just asking when the next release date is, not asking to expidite)

Thanks for clarifying about the child interpreter. At the moment, the only request I have about it, is just to document the constructor declaration about its behavior , especially since I wouldn’t have known that otherwise.

Hey Axel,

The following code produces the following output. Am I doing this wrong or is this a bug? This is from the master branch as of 30 minutes ago.

[code]
#include
#include

#include <cling/Interpreter/Interpreter.h>

//static const std::string PATH_TO_LLVM {"/home/d4nf/Custom_Libs/Root-CERN/root-6.06.00.gcc530/etc/cling"};
static const std::string PATH_TO_LLVM {"/home/d4nf/Custom_Libs/Root-CERN/root-cern-1-26-15.gcc530/etc/cling"};
static const char * clingArgs[] = {"", “-std=c++11”};
int main()

{
cling::Interpreter inter(2, clingArgs, PATH_TO_LLVM.c_str());
//inter.DumpIncludePath();
inter.declare("#include \n");
inter.process(“double d = 324.342;\n”);
inter.process(“std::cout << d << std::endl;\n”);
cling::Interpreter * inter2 = new cling::Interpreter(inter, 2,clingArgs,PATH_TO_LLVM.c_str());
inter2->process(“std::cout << d << std::endl”);
}[/code]

[quote]324.342
error: cannot import unsupported AST node SubstTemplateTypeParm
input_line_1:2:7: error: no member named ‘cout’ in namespace 'std’
std::cout << d << std::endl

input_line_1:2:25: error: no member named 'endl' in namespace 'std'
std::cout << d << std::endl
[/quote]

Hi,

We are extending the ASTImporter with the clang people; SubstTemplateTypeParm is one of the missing ingredients. You are very welcome to help! Let me know so we can coordinate. (And apologies for the late reply; this slipped through…)

Cheers, Axel.

Hey Axel,

I would love to help! It would take me a bit of time to get more familiar with the cling codebase, so any guidaance on how to get started would be appreciated :slight_smile:

Hi,

Take a look here: github.com/karies/root/pull/162 and check whether it fixed your SubstTemplateTypeParm issue - and report taht, report the next issue, and then take the existing PRs as guidance on how to implement that :wink:

Cheers, Axel.