The handling of the ifstream is very confusing, the while loop is
almost impossible to parse without major dissection, and its very
hackish. Since this primer is targeted at a quickstart for students,
I think it may be better to write it as:
It might be to support prehistoric compilers or interpreters which didn’t support bool types, but it is still more complicated than the typical workaround I am aware of: while(!!(inp >> x)) { }. Also definitely not an approach beginners should be taught today.
You should make a diff (against the git repository). The doc files you need to modify (in the markdown format)
in the trunk version of ROOT: $ROOTSYS/docbook/primer/*.md
before somebody suggests something complicated I am attaching a patch implementing the idiomatic version. This should apply cleanly with git am some_patch.C on the tip of master (and it would be great if filenames ending in .patch weren’t banned on this board). 0001-Use-more-idiomatic-way-to-read-from-file_patch.C (871 Bytes)
Sorry, I have to admit I didn’t even try to run that code. In the current form (while(inp>>x){…}) is much easier to parse by eye than the previous one. Thanks for telling me how to submit patches for the future, even if I didn’t get this one done.