Pass by reference in documentation

Hello, I would like to suggest that the “pass by reference” issue be more prominently featured in the PyROOT documentation. I am talking about the issue addressed here:

[url]Call by reference

From the point of view of a PyROOT user who wishes to avoid using raw ROOT (and C++) as much as possible, this is much more important than say, how to include custom C++ classes in PyROOT. It is also a problem that users run into while doing high-level work with histograms, and is not at all obvious how to fix.

Additionally, the message showed to users when mistakenly trying to use pass-by-reference functions could be made a bit more precise, currently it says:

TypeError: void TH1::GetBinXYZ(Int_t binglobal, Int_t& binx, Int_t& biny, Int_t& binz) => could not convert argument 2 (use ROOT.Long for pass-by-ref of ints)
but when I first saw this I did not know what pass-by-ref meant. Perhaps something like “Pass a ROOT.Long() variable when a ROOT function expects an Int_t& argument.”


1 Like


perhaps so, but the docs were written when pass-by-non-const-ref wasn’t yet a supported feature and they haven’t been updated since (not since 2006, in fact). Standard problem of lack of time and management that thinks code is the only thing that counts.

My intention is to do better for PyPy/cppyy and PyCling (although the former doesn’t support pass-by-non-const-ref yet, and the latter does not exist yet).