next up previous

9.4.4.1 Instance Initialization

Syntax

(defmessage-handler USER init primary ())

This handler is responsible for initializing instances with class default values after creation. The make-instance and initialize-instance functions send the init message to an instance (see sections 9.6.1 and 9.6.2); the user should never send this message directly. This handler is implemented using the init-slots function (see section 12.13). User-defined init handlers should not prevent the system message-handler from responding to an init message (see section 9.5.3).

Example

CLIPS> (clear)
CLIPS>
(defclass CAR (is-a USER)
  (role concrete)
  (slot price (default 75000))
  (slot model (default Corniche)))
CLIPS> (watch messages)
CLIPS> (watch message-handlers)
CLIPS> (make-instance Rolls-Royce of CAR)
MSG >> init ED:1 (<Instance-Rolls-Royce>)
HND >> init primary in class USER
       ED:1 (<Instance-Rolls-Royce>)
HND << init primary in class USER
       ED:1 (<Instance-Rolls-Royce>)
MSG << init ED:1 (<Instance-Rolls-Royce>)
[Rolls-Royce]
CLIPS>


next up previous