In the documentation ref/$ModuleNumber, I read:
Every Wolfram System session starts with $ModuleNumber set to 1.
Yet, when I quit Mathematica 10.1 (OS X 10.10.4), restart it, open a new notebook and enter:
In:= $ModuleNumber Out= 1370
Something wrong here?
Secondly, in the documentation ref/$ModuleNumber, I read:
$ModuleNumber is incremented every time Module or Unique is called.
Yet, each time I enter $ModuleNumber, it is updated.
In:= $ModuleNumber Out= 1869 In:= $ModuleNumber Out= 1870 In:= $ModuleNumber Out= 1871
And it doesn't start with 1371. Something strange going on?
P.S. I also got the same results when I shut my machine down, then restarted the machine, then restarted Mathematica.
Feedback from Wolfram Technical Support:
Thanks for contacting Wolfram Technical Support and for taking the time to send in the feedback. I agree with you that the documentation is misleading, but the observed behaviour is as designed.
Everytime Mathematica is launched, the \$ModuleNumber does reset to 1. However during the startup process, a lot of system-level functions will get loaded and many of them will localize their variables and therefore change the \$ModuleNumber counter. So when you start to evaluate your own statement, the \$ModuleNumber will be set to a different number.
Similarly, when you evaluate a command in the front-end, the communication between the front-end and the kernel also uses functions that will change the counter. This is why even if you simply do an evaluation, the \$ModuleNumber will increase. This is not specific to the evaluation of \$ModuleNumber, but any evaluations happen in the frontend.
We are sorry for the confusion caused by the documentation. Please let me know if you have further concerns.