10.4.5 Init expressions
An init expression is another way of providing a default slot value. Here is an example:
define class <time-of-day> (<time>) inherited slot total-seconds = get-current-time(); end class <time-of-day>;
Every time that we make an instance of the <time-of-day> class and we need a default value for the total-seconds slot, the expression get-current-time(); is evaluated to provide an initial value.
An init expression specifies an expression. Every time that an instance is made and the slot needs a default value, this expression is evaluated and its value is used as the default.
Notice the similarity between the init-function: slot option and an init expression. In fact, the following slot specifications are equivalent:
inherited slot total-seconds, init-function: get-current-time; inherited slot total-seconds = get-current-time();
That substitution works for functions that have no required arguments. More generally, the following slot specifications are equivalent:
slot slot = expression; slot slot, init-function: method () expression end method;
The expression can be a call to a function that requires arguments. Here, we use method to define a method with no name.
The init-value: slot option, init-function: slot option, and init expression are mutually exclusive. A given slot specification can have only one of these.




