next up previous

9.3.3.6 Source Facet

When obtaining slots from the class precedence list during instance creation, the default behavior is to take the facets from the most specific class which gives the slot and give default values to any unspecified facets. This is the behavior specified by the exclusive facet. The composite facet causes facets which are not explicitly specified by the most specific class to be taken from the next most specific class. Thus, in an overlay fashion, the facets of an instance's slot can be specified by more than one class. Note that even though facets may be taken from superclasses, the slot is still considered to reside in the new class for purposes of visibility (see section 9.3.3.8). One good example of a use of this feature is to pick up a slot definition and change only its default value for a new derived class.

Example

CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
  (multislot foo (access read-only)
                 (default a b c)))
CLIPS>
(defclass B (is-a A)
    (slot foo (source composite) ; multiple and read-only
                               ; from class A
            (default d e f)))
CLIPS> (describe-class B)
===============================================================
***************************************************************
Abstract: direct instances of this class cannot be created.
Direct Superclasses: A
Inheritance Precedence: B A USER OBJECT
Direct Subclasses:
---------------------------------------------------------------
SLOTS : FLD DEF PRP ACC STO MCH SRC VIS CRT OVRD-MSG SOURCE(S)
foo   : MLT STC INH  R  LCL RCT CMP PRV NIL NIL      A B
Constraint information for slots:
SLOTS : SYM STR INN INA EXA FTA INT FLT
foo   :  +   +   +   +   +   +   +   +  RNG:[-oo..+oo] CRD:[0..+oo]
---------------------------------------------------------------
Recognized message-handlers:
init primary in class USER
delete primary in class USER
print primary in class USER
direct-modify primary in class USER
message-modify primary in class USER
direct-duplicate primary in class USER
message-duplicate primary in class USER
***************************************************************
===============================================================
CLIPS>


next up previous