Dictionaries in CINT and cling

Hi,

Marcelo asked about how I see the future of dictionaries with cling, if we manage to replace CINT with cling. Given that many people probably don't know what those "dictionaries" really do, I decided to post it! I'll keep it as simple and short as possible.

CINT sees code that you enter as strings, e.g. TGraph g(12); is really "TGraph g(12);". It analyzes the input, sees that a variable g of type TGraph is declared. Then there is a constructor to be called, the one taking an int. Now, several things need to happen:

  • Overload resolution: which constructors are there, which one should be invoked for an argument list (int)? CINT stores the available functions in the dictionary, with their names and argument and return types as strings.
  • CINT needs to be able to call that constructor. Those are the G__cpp... functions ("wrappers" or "stubs") in the dictionary: they all have the same signature, and convert from a void* array to the function's actual parameter types.
  • The argument is "12", that needs to be converted into an integer value of 12 so it can be passed to the constructor.

ROOT I/O needs that, too: when reading an object's data from a ROOT file, it creates the object in memory (calling the default constructor) and then sets the data members to the values read from disk. To not do the complex steps above, ROOT stores a shortcut in the dictionary. There are more shortcuts in the dictionary, e.g. to tell ROOT how to create the TClass object for a class. And the dictionary implements functions that are declared by using ClassDef(), e.g. Streamer(), ShowMembers(). ClassImp() is basically unused nowadays, it's just for THtml to find the source file.

Part of cling is a compiler, clang. Of course for a compiler, #include "TObject.h" has all the information to describe the class. It is as good as a dictionary for TObject. What's missing are suppressions of classes, i.e. classes that should not be used for I/O or within the interpreter - but that we can add independently. And because clang uses llvm and its just-in-time compiler we can call functions without stubs from CINT's dictionary.

The only missing part are the implementations of the ClassDef() functions. We don't need to generate them as source anymore; if we really need them we can just-in-time compile them. But we believe we can just get rid of them.

As you can see there is nothing left from the dictionaries: a simple #include "TObject.h" (or its precompiled header) is enough for cling! So let's cross our fingers that Vassil can stay with us and that we can pull it off: cling and its integration into ROOT!

Cheers,
Axel

Is it really necessary to

Is it really necessary to replace CINT dictionary with cling? I spent many years fighting with incomplete or sometimes wrong implementation of C/C++ by CINT. I am highly skeptical if we need another HEP developed compiler. Can we stick to industry standards? For example, ATLAS now uses gcc xml with reflex for dictionary and it works great, no more obscure CINT errors. Similarly, we can use python for macros and as an interactive interpreter. I really think that extending PyROOT capability would be extremely useful. Just my two cents.

Re: Necessary?

Hi ROOT user

Excellent comments, thanks a lot!

As a matter of fact I find your comments too good to just deal with them in a comment reply. Instead I'll try to answer them (probably next week - just back from vacation) through a separate blog post.

Again - thanks for taking the time to write your comments; they allow me to understand how people perceive cling and what we need to explain better! I hope I'll manage. And if not you will have a platform to discuss :-)

Cheers, Axel.

Hoping to improve STL interface in ROOT

Dear Alex, I am interesting in this topic in anticipation of solving my problems with STL containers of user classes (like std::list). I am not able to make dictionary for them and only simple containers like list work on my pc. I must note that I use pre-installed ROOT under Athena framework (ATLAS) Libor

STL dictionaries

Hi Libor,

Thanks for your comment! STL is one of the weaknesses of a real C++ interpreter: it needs to interpret the templated functions on the fly, and that's tricky code and very platform dependent, see e.g. __push_heap() in /usr/include/c++/4.5/bits/stl_heap.h. If the cling project succeeds it should solve our problems with STL, simply because it's all complied by a "proper" compiler library: clang.

That said, of course you should be able to create dictionaries for your STL containers. If you cannot you should post e.g. to the ROOT forum.

Cheers, Axel.

Hi Axel, thanks again. I am

Hi Axel, thanks again. I am looking forward to hearing from you about progress regarding ROOT I/O, dictionaries, cling etc. My analysis code uses most of these ROOT features, therefore the interest.

ROOT I/O

Hi Marcelo,

Thanks for your comments and your interest! I'll definitely keep posting about progress we make. There are several developments in the queue related to I/O, but I prefer to post when it's done, not when it's planned :-)

Cheers, Axel.