According to the Solidity documentation,
For almost all types, you cannot specify where they should be stored, because they are copied every time they are used.
I have played around with this in Remix trying to understand it with the following code. I would expect that by adding "storage" to the "inc" function, I could use it to change multiple global uints, but "storage" is reserved for structs and arrays.
I'm having trouble understanding the reasoning behind this - that this can't be done "because they are copied every time they are used". I take this to mean that every time a uint is used in a function, a copy is made to memory - and nothing can be done about that. But I can alter a global uint within a function by saying, for example, "number1 += 1", and this will save to the state. So, I don't understand why a copy must be made each time.
pragma solidity ^0.4.0;
contract C {
uint public number1;
uint public number2;
function incOne() public view {
inc(number1);
}
function incTwo() public view {
inc(number2);
}
function inc(uint storage d) internal pure {
d += 1;
}
}