Four functions are provided for modifying instances. These functions allow instance slot updates to be performed in blocks without requiring a series of put- messages. Each of these functions returns the symbol TRUE if successful, otherwise the symbol FALSE is returned.
The modify-instance function uses the direct-modify message to change the values of the instance. Object pattern-matching is delayed until all of the slot modifications have been performed.
Syntax
(modify-instance <instance> <slot-override>*)
Example
CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
(role concrete)
(slot foo)
(slot bar))
CLIPS> (make-instance a of A)
[a]
CLIPS> (watch all)
CLIPS> (modify-instance a (foo 0))
MSG >> direct-modify ED:1 (<Instance-a> <Pointer-0019CD5A>)
HND >> direct-modify primary in class USER.
ED:1 (<Instance-a> <Pointer-0019CD5A>)
::= local slot foo in instance a <- 0
HND << direct-modify primary in class USER.
ED:1 (<Instance-a> <Pointer-0019CD5A>)
MSG << direct-modify ED:1 (<Instance-a> <Pointer-0019CD5A>)
TRUE
CLIPS> (unwatch all)
CLIPS>
The active-modify-instance function uses the direct-modify message to change the values of the instance. Object pattern-matching occurs as slot modifications are being performed.
Syntax
(active-modify-instance <instance> <slot-override>*)
The message-modify-instance function uses the messagemodify message to change the values of the instance. Object pattern-matching is delayed until all of the slot modifications have been performed.
Syntax
(message-modify-instance <instance> <slot-override>*)
Example
CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
(role concrete)
(slot foo)
(slot bar (create-accessor write)))
CLIPS> (make-instance a of A)
[a]
CLIPS> (watch all)
CLIPS> (message-modify-instance a (bar 4))
MSG >> message-modify ED:1 (<Instance-a> <Pointer-009F04A0>)
HND >> message-modify primary in class USER
ED:1 (<Instance-a> <Pointer-009F04A0>)
MSG >> put-bar ED:2 (<Instance-a> 4)
HND >> put-bar primary in class A
ED:2 (<Instance-a> 4)
::= local slot bar in instance a <- 4
HND << put-bar primary in class A
ED:2 (<Instance-a> 4)
MSG << put-bar ED:2 (<Instance-a> 4)
HND << message-modify primary in class USER
ED:1 (<Instance-a> <Pointer-009F04A0>)
MSG << message-modify ED:1 (<Instance-a> <Pointer-009F04A0>)
TRUE
CLIPS> (unwatch all)
CLIPS>
The active-message-modify-instance function uses the message-modify message to change the values of the instance. Object pattern-matching occurs as slot modifications are being performed.
Syntax
(active-message-modify-instance <instance> <slot-override>*)