| OCR Text |
Show 28 cally included as a component of all other flavors. By writing a customized method, the programmer can override this default and is thus able to control the format of these printed representations. The Lisp Printer (of the "read-eval-print" trio) which sends the :PRINT-SELF message to random objects remains intact; all the programmer does is to change the way this message is received. For example: (DEFMETHOD (TILESET :PRINT-SELF) (STR &REST IGNORE) (IF (INSTANCE-VARIABLE-BOUNDP NAME) (FORMAT STR "#<-A -A>" (TYPEP SELF) NAME) ; ; otherwise (FORMAT STR "#<-A -O>" (TYPEP SELF) (%POINTER SELF) ) ) ) (MAKE-INSTANCE 'TILESET) => #<TILESET 07162534>1 (MAKE-INSTANCE 'TILESET :NAME 'NMOS40) => #<TILESET NMOS40> There are several methods that can be defined that need only know about the state of the grid maintained by the GRID-MIXIN, which state and which methods will be inherited by the "parent" grid flavor. In reviewing these and other methods, the message name that invokes them will be mentioned, along with a brief description of what they do; however, detailed documentation is more "programmer's reference" flavor than would be palatable here, and is therefore relegated to Appendix B. There are three GRID-MIXIN methods that are used frequently by INSTED. The :TILES method returns a list of all tiles in the whole plane, or part of it; :FIND-TILE returns the tile at a given grid location; and :PLACE-NEW-TILE places a newlyinstantiated tile object on the grid. Since tiles are central to grid methods, it is fitting that they be examined more closely. Accordingly, the tile flavor definition is shown in Figure 7, along with a short, explanatory, (egocentric!) comment next to each instance variable name. Unlike those of the BASIC-GRID flavor, most TILE instance variables are not in-itialized via an init-plist. The reason for this is simple. When many tiles are being rapidly instantiated, the time efficiency of that creation process is crucial. While initplists are one way to maintain templates for tile instantiation, there is another way that 1This (octal) number is a pointer to the virtual memory address where the object "lives." Since no two instances have the same pointer, including this number in the printed representation is an expedient (albeit inelegant) way to visually distinguish them. |