Named Arguments and Passing NULL/nullptr

Hi, I recently tried to use a constructor where I wanted to manually give the default argument. In TGraphErrors in the constructor with array pointers, if the pointer is null, it defaults to zero-values. I tried giving 0 or ROOT.NULL, etc, but nothing works. I ended up manually filling an array of zeros to give to the constructor. I couldn’t just let the machine use the default argument because I was using non-default values for later arguments.

What is the best way to provide a NULL/nullptr to a ROOT constructor or function, or a null-but-typed pointer? Is there a way to generate one on the ROOT side?

I found this four-year-old post: [url]How to pass a NULL pointer as a function argument? talking about this, and one of the solutions was using named arguments to allow out-of-order function signatures. This would allow me to specify non-default values for later arguments while retaining the default null values for preceding arguments. Has anything been done to implement this? I’d very much be in favour of auto-generated named arguments from the ROOT source.



one of them thingies …

I’ve added an identifiable object called nullptr in v5-34-00-patches (thinking ahead for C++11, of course). This is a capsule, so useless for any purpose other than to extract a NULL value. In effect, this allows the programmer to tell PyROOT that “yes, that NULL was intentional.”

[code]>>> import ROOT

g = ROOT.TGraphErrors(0, ROOT.nullptr, ROOT.nullptr)

In CINT, NULL is available as a macro. On Cling, it’s actually not available, but I simply added it as a python int ‘0’. Python caches small ints, so id(ROOT.NULL) == id(0). I have to think a bit about the consequences, but I expect that it’s best for ROOT.NULL to ‘is’ ROOT.nullptr in ROOT6.

Haven’t worked on keywords since that other thread (another one of them thingies).