Solidity functions can be marked with constant modifier, meaning theoretically that the execution does not cost gas, because the function is run only by a local node. However making a couple of simulations and measurements constant functions work a little bit funny at the moment.
- If the constant function is called directly from outside: it does not cost gas.
- If the constant function is called by another non-constant function but from the same contract: it does not cost gas.
- If the constant function is called by another non-constant function which is located in a different contract: it does cost gas.
If the constant function is called by another constant function which is located in a different contract: it does not cost gas.
Certainly it is an interesting question how will it work in the future, as the constant modifier will be replaced in the future by two ones: view and pure. However, as a conclusion we might as well conclude generally that even if with such a modifiers, there is not always a gas savings.