I thought that many object-oriented languages have a reserved keyword for methods which do not modify the state of an object. These methods often have names that start with get. AFAIK a "getter" is always related to a single object attribute and "accessor" is too general, so "readonly" may the right term for this kind of methods (?). To give an example:
object Timespan {
attribute start
attribute end
// getter, not changing the state
readonly method getStart { return start }
readonly method getEnd { return end }
// also not changing the state
readonly method getDuration { return ( end - start ) }
}
The compiler/interpreter should check that readonly methods have no side-effect by modifying object attributes. I wonder why this language feature is not more common - just naming a method getFoo does not ensure that it won't modify the object.