You omitted that toInt(&ok) is required to test ok for null, which is not 
required if ok is a reference.


martin

________________________________
From: [email protected] 
<[email protected]> on behalf of 
Andreas Aardal Hanssen <[email protected]>
Sent: Monday, May 18, 2015 12:10 PM
To: development
Subject: [Development] Fwd: QTextStream::readLine(0) is an ambiguous overload 
in 5.5


2015-05-18 11:54 GMT+02:00 Smith Martin 
<[email protected]<mailto:[email protected]>>:

When I'm reading code and I encounter a function call with parameters, if I am 
not familiar with that function, I look at its documentation. First I look at 
the signature. If it contains a non-const reference, I know the parameter can 
be modified. I read the function documentation to see if it is meant to be 
modified.

What is required inside the function if a pointer is used instead? Is the 
function required to test the pointer for nil and return in an error state or 
report an error? That doesn't happen with a reference.

Hi Martin :-).

IMO Qt's first level of helpfulness is its API. The code should be 
self-explaining and self-documenting if possible. Then, if you cannot figure 
out what a function does, Qt provides first class documentation. Which is why 
QList has append and prepend instead of push_back and push_front :-).

bool ok = false;
int foo = variable.toInt(ok); // need doc
int foo = variable.toInt(&ok); // dont need doc

Again though, this is procrastinating. Unless something significant has changed 
in C++ the last 10 years with regards to pointers and references I'd just 
continue sticking to what has always been the convention. Otherwise going 
through all Qt's api and changing it from pointers to references would be 
required. IMO.

--
Andreas Aardal Hanssen


_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to