chapter11 - Chapter 11: Classes, Instances, and...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 11: Classes, Instances, and Message- Handlers Expert Systems: Principles and Programming, Fourth Edition
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 2 The Defclass Construct Before instances of classes can be created, CLIPS needs to know the list of valid slots for the given class. To provide this information, the defclass construct is used: (defclass <class-name> [<optional- comment>] (is-a <superclass-name>) <slot-definition>*)
Background image of page 2
Expert Systems: Principles and Programming, Fourth Edition 3 The Defclass Construct Note that <superclass-name> is the class from which the newly defined class will inherit information. All user-defined classes ultimately inherit from the system class USER. A user-defined class will therefore inherit from the USER class or from another user-defined class.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 4 The Slot Definition The syntax of the <slot-definition> is: (slot <slot-name> <slot-attribute>* | (multislot <slot-name> <slot-attribute>*) type, range, cardinality, allowed-symbols allowed-strings, allowed-lexemes, allowed-integers allowed-floats, allowed-numbers, allowed-values allowed-instance-names, default, and default-dynamic
Background image of page 4
Expert Systems: Principles and Programming, Fourth Edition 5 Creating Instances To create an instance of a class, use the make- instance command as follows: (make-instance [<instance-name-expression>] of <class-name-expression> <slot-override>*) where <slot-override> is: (<slot-name-expression> <expression>) Instances belong to the module in which their corresponding defclass is defined.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 6 System-Defined Message- Handlers Just like data, procedural information can be attached to classes. Such procedures are called message-handlers. User-defined System-defined – automatically created Message handlers can be invoked for an instance (object) using the send command. (send <object-expression> <message-name-expression> <expression>*)
Background image of page 6
Expert Systems: Principles and Programming, Fourth Edition 7 System Message-Handlers For each slot defined in a defclass , CLIPS automatically defines get- and put- slot message- handlers that are used to retrieve and set slot values. The get -message-handlers have no arguments and return the value of the slot. The put -message-handlers take zero or more arguments. If not arguments are supplied, the slot is restored to its original default-value.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Expert Systems: Principles and Programming, Fourth Edition 8 System Message-Handlers Supplying the arguments will set the slot value to those values. The return value of a put -message-handler is the new value of the slot. When slots are being watched, an informational
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2010 for the course IT expert sys taught by Professor Dr. during the Spring '10 term at Dubai Aerospace Enterprise University.

Page1 / 42

chapter11 - Chapter 11: Classes, Instances, and...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online