| OCR Text |
Show 25 2.6 Tasteful flavors The DEFFLAVOR macro provides a number of very powerful and convenient mechanisms for defining ADT's, or flavors. Refer to Figure 6 for the DEFFLAVOR forms of three fundamentaliNSTED flavors: Tileset, Basic-Grid, and Grid-Mixin. The TILESET flavor is defined to have five instance variables, the last of which is given a default initialization via the (MAKE-HASH-TABLE) form. This form will be evaluated when a tileset object is instantiated,1 unless the instance variable is initialized in some other way (see footnote,) whence its "default" nature. The "()" represents an empty list. If it is non-empty, as in the case of the GRID-MIXIN flavor, it triggers the flavor inheritance mechanism, making the defined flavor inherit instance variables and methods from all flavors whose names are in the list, which in this case is just the BASIC-GRID. The BASIC-GRID flavor depends entirely on the TILESET flavor, not by inheritance, but in the sense that its instance variables are initialized from the GRID-INIT-PLIST of the tileset object, since most of them are supplied or derived attributes of the grid defined by DEFTILESET. The PORT-DESCRIPTORS, PORT-NAMES and PORT-MAP instance vari-abies, derived to deal with ports of course, will be described in Chapter 3. While the GRID-MIXIN flavor depends on the BASIC-GRID flavor for its "basic" instance variables, it supplies a few itself. PLANE, WINDOW-X-POS and WINDOW-Y-POS have been previously introduced. The default value of zero for these last two signifies that the initial view corresponds to the first quadrant of the plane. The view moves to the right as WINDOW-X-POS increases, and to the left as it decreases. Likewise, the view moves up as WINDOW-Y-POS increases, and down as it decreases. WINDOW-X-SIZE and WINDOW-Y-SIZE give the dimensions of the viewing window in "grid" units. REGIONS and LABELS are lists containing all instances of these kinds of objects, whose role will be discussed in Chapter 4. 1A flavor instance is created by calling either MAKE-INSTANCE or INSTANTIATE-FLAVOR; both are passed a required argument which is the name of the flavor being instantiated, but each takes additional optional arguments differently. MAKE-INSTANCE takes alternating init-keywords and values, while INSTANTIATE-FLAVOR takes a list of these- the init-plist, of course. The : INITABLE-INSTANCE-VARIABLES option allows the user to specify which instance variables may be thus initialized upon instantiation, by including their names in this list. The form shown means all of them are "initable." |