next up previous

9.3.3.8 Visibility Facet

Normally, only message-handlers attached to the class in which a slot is defined may directly access the slot. However, it is possible to allow message-handlers attached to superclasses or subclasses which inherit the slot to directly access the slot as well. Declaring the visibility facet to be private specifies that only the message-handlers of the defining class may directly access the slot, and this is the default. Declaring the visibility facet to be public specifies that the message-handlers of superclasses and subclasses which inherit the slot may also directly access the slot.

Example

CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
  (slot foo (visibility private)))
CLIPS>
(defclass B (is-a A)
  (role concrete))
CLIPS>
(defmessage-handler B get-foo ()
  ?self:foo)
[MSGFUN6] Private slot foo of class A cannot be accessed directly by handlers attached to class B
[PRCCODE3] Undefined variable self:foo referenced in message-handler.
ERROR:
(defmessage-handler MAIN::B get-foo
   ()
   ?self:foo
   )
CLIPS>


next up previous