Re: memory transition between interpreter / compiled was:

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 15 Aug 2007 12:42:28 +0200


Hi Christian Holm,

Christian Holm Christensen wrote:

>> TString inst = Form("int *a=0x%x; std::cout << \"a inside = \" << *a <<
>> std::endl;", &a;
>> gROOT->ProcessLine(inst);

> Suppose,
> that 'a' is some complex object (not excluding POD) - since the exact
> layout in memory of a complex object is not necessarily predictable nor
> known to CINT

This is not the case. The dictionary ensures that CINT knows what the object looks like in memory. In fact, CINT handles objects of compiled types internally only as pointers to the objects (yes, it's obvious, but still), and can access data members and copy these objects nevertheless.

> Note, that the global interpreter scope has no parallel in real C++, in
> that you cannot have executable statements outside of function or member
> function scope.

Even worse, the "global interpreter scope" is actually a global per-file scope; its variables go out of scope if their file or any file loaded before them gets unloaded.

> In fact, ROOT should implement some sort of
> singleton manager for most of it's global variables, like gROOT, gPad,
> gApplication, gStyle, and so on.

We have - if you check the current implementation, many of those are function calls hidden as CPP macros. CINT sees the result of the function call; see TROOT::FindSpecialObject().

> So, please try _not_ to use the hack Axel proposed. Instead, make a
> singleton manager or make the variable truly global in the interpreter
> scope.

I agree with your suggestion to improve the design (e.g. using a singleton). But the transition between compiled and interpreted world is via pointers, so IMHO it's fine to pass pointers between them. But that's merely an opinion - just like Christian Holm's statement :-)

Axel. Received on Wed Aug 15 2007 - 12:42:34 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 16 2007 - 17:50:02 CEST