Request: Default base for TString::Itoa and friends

I am wondering why the TString::Itoa method does not have a default base argument. It should have a default argument for base 10, since that is what I imagine is most commonly desired. Several times I have had to search the docs to to find out that I had to explicitly specify base 10.

It doesn’t help that the CINT error message is not useful when one forgets the explicit base:

[code]* ROOT v5.34/10 *

root [0] TString::Itoa(10)
Error: Function Itoa(10) is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
[/code]
I am sometimes reminded if my guess is that the Itoa method is for some reason non-static and I need to construct a real TString before using its Itoa:

root [1] TString s
root [2] s.Itoa(10)
Error: Can't call TString::Itoa(10) in current scope (tmpfile):1:
Possible candidates are...
public: static TString TString::Itoa(Int_t value,Int_t base); //Converts int to string with respect to the base specified (2-36)
*** Interpreter error recovered ***

Is there any reason not to add a default base of 10 to the Itoa & related methods (LLtoa, UItoa, etc)? At the very least, using the static class method TString::Itoa incorrectly should give the same helpful error message as using an existing TString’s Itoa method.

Jean-François

I think, this is the matter of taste. A lot of people do not like default arguments and prefer explicit arguments/expressions. There are even coding styles prohibiting default arguments, I believe.
I personally prefer not to rely on any default argument and do not like them in general. What if some nerd writing his nice library thinks that default radix MUST BE 16 as soon as he loves to use hexadecimal system to do ALL arithmetics :slight_smile: And we as users now have strange values returned by his library while we’re passing reasonable decimal (???) numbers and using default argument (wait, it’s ‘= 10’, right?).

But yes, after all there is no harm in adding ‘= 10’ in TString::Itoa for already existing code at least.