[ Pobierz całość w formacie PDF ]
.LINE has two point-type slots.TRIANGLE has threeline-type slots.QUADRILATERAL has four line-type slots, and so on.Generalization isgood for synthesis, which means a building up.The opposite of synthesis is analysis,which means taking apart or a simplification.The model for analysis is specialization.Fig.10.1 illustrates one inheritance scheme for polygons in which classes are built byinheritance.In this case, the link between classes would be "is-made-of".Thus, a LINEis-made-of POINT.A POLYGON is-made-of LINE, and so forth.  136 USERPOINTLINEPOLYGONIRREGULAR REGULARPOLYGON POLYGONEQUILATERAL EQUILATERALSQUARETRIANGLE PENTAGONFig.10.1 Polygon Hierarchy Showing a Few Regular Polygon ClassesLinks such as "is-made-of" can be simulated in CLIPS by appropriate slot definitionseven though only is-a links are supported in Version 6.As an example ofgeneralization, let's build up a LINE class as a generalization of a POINT class.ThePOINT class will provide instances that have a position.In order to make this examplerealistic, we'll assume an arbitrary number of dimensions by defining the position as(multiple).Thus, a one-dimensional point will have one value in the position slot, a two-dimensional point will have two values, and so forth.The definition of the POINT class isvery simple.CLIPS> (clear)CLIPS> (defclass POINT (is-a USER)(multislot position (propagation no-inherit)))CLIPS>The (no-inherit) facet is used to prevent a LINE from inheriting a position slot.Instead, a  137 LINE will be defined by two points called slot point1 and slot point2.These two slots willdefine the line and it is extraneous to have an additional position slot by inheritance.The definition of the LINE class is a little more complex.The reason for the addedcomplexity is that the details of implementation are included in the (defclass) becauseVersion 6.0 only supports is-a relationships.(defclass LINE (is-a POINT)(slot point1 (default-dynamic (make-instance (gensym*) ofPOINT))(propagation no-inherit))(slot point2 (default-dynamic (make-instance (gensym*) ofPOINT))(propagation no-inherit))(message-handler find-point)(message-handler print-points)(message-handler find-distance)(message-handler print-distance))Note that the message-handlers of LINE are forward-declared for documentationpurposes.At this time you may be wondering why POINT and LINE are not both defined assubclasses of USER since all their slots have (no-inherit) facets.Since all the slots ofPOINT, LINE, and the TRIANGLE class to be defined later have (no-inherit) facets, allthese classes could be defined as direct subclasses of USER rather than defining LINEas a subclass of POINT and TRIANGLE as a subclass of LINE.However, the whole point of this example is to illustrate Inheritance by Generalization,which is a logical concept that is not directly supported by Version 6.Thus, definingLINE as a subclass of POINT and TRIANGLE as a subclass of LINE is done for reasonsof documenting the logical concept of Inheritance by Generalization.Admittedly, acomment could be added by the (defclass LINE (is-a USER)) and (defclass TRIANGLE(is-a USER)) stating that we are trying to implement Inheritance by Generalization, butseeing the code in place is better documentation.If Inheritance by Generalization isever directly supported by CLIPS, these (defclass) statements will make it easy toconvert.The reason for including the (make-instance (gensym*)) in the LINE slots is to providethe inheritance from the POINT class.With the standard Inheritance by Specialization,only one position slot of LINE is possible because POINT has only one position slot.It isnot possible for both slot point1 and slot point2 of LINE to inherit the position slot of  138 POINT.The actual slot value of each LINE will be a gensym* value.Each gensym*value will be the instance name of a point instance.The point position can then beaccessed through the gensym* value.Thus, the gensym* values act as pointers todifferent instances.This indirect access technique of (gensym*) values is analogous to using a pointerto access a value in a procedural language.Thus, the different slots of LINE canindirectly inherit the same slots of POINT.It's convenient to use (gensym*) because wedon't care what the pointer names of LINE are, any more than we care what the pointeraddresses are in a procedural language.The following examples show how the points are accessed for one-dimensionalpoints at position 0 and 1 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • zambezia2013.opx.pl
  • Podstrony

    Strona startowa
    LU. VII IX. Hasek Jaroslaw Przygody Dobrego Wojaka Szwejka
    Kerry Allyne Reunion at Pitereeka (pdf)
    Christie, Agatha Poirot rechnet ab
    Miller Andrew Casanova zakochany
    Weeks Brent Nocny Anioł 03 Poza Cieniem 2
    Edwardson ake Erik Winter 02 Wolanie z oddali
    Plaidy Jean Katarzyna Aragonska tom 3
    Tomasz Bielak Miroslaw Filiciak Grzegorz Ptaszek Zmierzch telewizji Przemiany medium Antologia
    Weissberg Cybulski Aleksander Wielka czystka
    Evans Nicholas Odwazni
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • briefing.htw.pl