4.4 Getters and setters of slot values
We can store a value in the total-seconds slot of the <time-of-day> instance by using the assignment operator, :=, as follows:
? *my-time-of-day*.total-seconds := 180; 180
We can examine the value of the slot in the instance:
? *my-time-of-day*.total-seconds; 180
Although these expressions may look like they are accessing the slots directly, they are not. They are abbreviations for function calls to a getter and a setter. A getter is a method that retrieves the current value of a slot in an object. A setter is a method that stores a value in a slot. Each slot in a class automatically has a getter and a setter defined for it. You can see the function-call syntax, and other information about getters and setters, in Chapter 10, Slots.




