The nonmutating method hint is a little bit confusing to me.
It is said (p.83):
interface Clock {
nonmutating TimeOfDay getTime();
void setTime(TimeOfDay time);
};
Quote:
|
The nonmutating keyword indicates that the getTime operation does not change the state of its object.
|
I have hard time understanding what an "object state" is given i am supposed to work only against interfaces that can be mapped to any implementation on the server side.
You also explain that the nonmutating hint means that (given a set of parameters ?), the method can be called more than once before returning without harm: I understand that this is the interface designer choice to make some methods nonmutating or not, and that this choice is often made with an implementation in mind.
For example, it effectively does not harm to call getTime() many times, even if the Clock implementation on the server is a real-time Clock (and not just an object with a TimeOfDay property).
The same reasoning may apply to interfaces that do not store any state by themselves, for example a proxy to make predefined requests to a database, even if the result may be different between the different call attempts.
Is this point of view compatible with your definition of the nonmutating keyword?
--
Christophe