;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*- ;;; Patch file for System version 126.72 ;;; Reason: ;;; Major cleanup of (what was a mostly useless) documentation string for ;;; DEFFLAVOR. ;;; Written 8-Sep-88 01:51:39 by keith (Keith Corbett) at site Gigamos Cambridge ;;; while running on Breaking Glass from band 3 ;;; with Experimental System 126.71, Experimental ZWEI 126.8, Experimental ZMail 74.1, Experimental Local-File 76.0, Experimental File-Server 25.0, Experimental Unix-Interface 14.0, Experimental Tape 25.1, Experimental Lambda-Diag 18.0, microcode 1762, SDU Boot Tape 3.14, SDU ROM 103, Lambda/Falcon Development System. ; From modified file DJ: L.SYS2; FLAVOR.LISP#320 at 8-Sep-88 02:13:27 #8R SYSTEM-INTERNALS#: (COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SYSTEM-INTERNALS"))) (COMPILER::PATCH-SOURCE-FILE "SYS: SYS2; FLAVOR  " (DEFMACRO DEFFLAVOR (NAME INSTANCE-VARIABLES COMPONENT-FLAVORS &REST OPTIONS) "Defines a class of Flavor data-structures known as NAME, built on COMPONENT-FLAVORS, that contains INSTANCE-VARIABLES. / INSTANCE-VARIABLES is a list; each element may be a symbol, or a list of a symbol and initialization form. / COMPONENT-FLAVORS are searched from left to right for methods, and contribute their instance variables. / OPTIONS include: - :GETTABLE-INSTANCE-VARIABLES (:GETTABLE-INSTANCE-VARIABLES var1 var2...) Methods are automatically generated for the listed instance variables for retrieving their values. Method names are keywords. For the atomic form, methods are automatically generated for retrieving the values of all local instance variables (those declared in this DEFFLAVOR). - :INITTABLE-INSTANCE-VARIABLES (:INITTABLE-INSTANCE-VARIABLES var1 var2...) These instance variables may be initialized via the options to MAKE-INSTANCE. - :SETTABLE-INSTANCE-VARIABLES (:SETTABLE-INSTANCE-VARIABLES var1 var2...) Methods are automatically generated for the listed instance variables for changing their values. SETTABLE instance variables are also INITTABLE. - (:REQUIRED-INSTANCE-VARIABLES var1 var2...) Any flavor incorporating this flavor and actually instantiated must have instance variables with the specified names. This is typically used for defining general and abstract types of flavors. - (:REQUIRED-METHODS method1 method2...) Any flavor incorporating this flavor and actually instantiated must have methods for the specified operations. - (:REQUIRED-FLAVORS flavor1 flavor2...) Any flavor incorporating this flavor and actually instantiated must have the component flavors as specified. - (:INIT-KEYWORDS key1 key2...) Specifies legal keywords for the INIT-PLIST (keywords that can be passed as arguments to initialize instances of this flavor). This option may be used to avoid restrictions on initialization keywords. - (:DEFAULT-INIT-PLIST key1 val1 key2 val2...) Specifies default keyword//value pairs to put in the INIT-PLIST. The keywords are used only if are not already specified when instantiating. The corresponding values get evaluated when and only if they are used. - (:DEFAULT-HANDLER function) Specifies a function to be called if a message is sent for which there is no corresponding method. The function is given the message name, and SELF is bound to the instance which was sent the message. The default is a function which signals an UNCLAIMED-MESSAGE condition. - (:INCLUDED-FLAVORS flavor1 flavor2...) Specifies flavors to be included in this flavor. This is different from specifying components in that included flavors go at the end, so they act as defaults. This makes a difference when this flavor is depended on by other flavors. - :NO-VANILLA-FLAVOR Do not automatically include VANILLA-FLAVOR. [For exotic purposes only.] - (:ORDERED-INSTANCE-VARIABLES var1 var2...) Requires that in any instance built on this flavor, the specified instance variables must reside in the specified memory order. Used internally, e.g. for slots specially referenced by microcode. The atomic form works too. - (:OUTSIDE-ACCESSIBLE-INSTANCE-VARIABLES var1 var2...) Defines DEFSUBSTs which act like DEFSTRUCT accessors for the specified variables. These functions, called with an argument of an instance, return the value of the corresponding instance variable within that instance. By default, the names of DEFSUBSTs are constructed as: -. If the instance variable is ordered, the accessor will know its index in the instance and access it directly; otherwise it will call SYMEVAL-IN-INSTANCE at run-time. The atomic form works too. - (:ACCESSOR-PREFIX symbol) For OUTSIDE-ACCESSIBLE-INSTANCE-VARIABLES, specifies a symbol as the prefix to use instead of the flavor name for the names of the generated DEFSUBSTs. - (:METHOD-ORDER method1 method2...) Specifies important method keywords, indicating methods that should reside first in the select-method lookup table for increased efficiency. - (:METHOD-COMBINATION (type order operation1 operation2...) ...) Specifies ways of combining methods from different flavors. :DAEMON NIL is the default. Order is usually :BASE-FLAVOR-FIRST or :BASE-FLAVOR-LAST, but this depends on type. - (:DOCUMENTATION args...) The list of arguments is put on the flavor's :DOCUMENTATION property. The arguments may include keyword symbols and documentation strings, which are used to construct the flavor's documentation (type FLAVOR). Typical keywords include :MIXIN, :ABSTRACT-FLAVOR, and :COMBINATION. For example: /(defflavor example ((example-thing /"example/")) (other-flavor) (:documentation :bogus /"Just an example./" :combination /"Illustration only./")) /(princ (documentation 'example 'flavor)) => Just an example. Illustration only. A BOGUS COMBINATION Flavor. - (:SPECIAL-INSTANCE-VARIABLES var1 var2 ...) Specifies instance variables that must be bound as SPECIAL (dynamic) when instances are sent messages. - :ABSTRACT-FLAVOR Prohibits instantiation; allows COMPILE-FLAVOR-METHODS without complaining about missing requirements. - :ALIAS-FLAVOR Specifies that this flavor has only one component and is an alias for it. This flavor may not have local instance variables, etc. Instantiating the alias flavor makes an instance of the true (component) flavor." (declare (zwei:indentation 1 10 3 1)) (declare (values name)) (LET ((COPIED-OPTIONS (COPYLIST OPTIONS))) `(PROGN ;; Define flavor at load time. ;; Must come before the compile-time COMPOSE-AUTOMATIC-METHODS, ;; which puts methods in the QFASL file. (EVAL-WHEN (LOAD EVAL) (DEFFLAVOR2 ',NAME ',INSTANCE-VARIABLES ',COMPONENT-FLAVORS ',COPIED-OPTIONS)) ;; Define the flavor if not loading. (EVAL-WHEN (COMPILE) (IF (JUST-COMPILING) (LET ((*JUST-COMPILING* T)) (DEFFLAVOR2 ',NAME ',INSTANCE-VARIABLES ',COMPONENT-FLAVORS ',COPIED-OPTIONS) ;; Compile the automatic instance-variable get/set methods into QFASL file (COMPOSE-AUTOMATIC-METHODS (COMPILATION-FLAVOR ',NAME))) ;; Compiling in editor buffer. Must define automatic methods for real now. (COMPOSE-AUTOMATIC-METHODS (GET ',NAME 'FLAVOR)))) (EVAL-WHEN (EVAL) ;; Create the instance-variable get/set methods if evaling. (COMPOSE-AUTOMATIC-METHODS (GET ',NAME 'FLAVOR))) (EVAL-WHEN (COMPILE LOAD EVAL) ;; Make any instance-variable accessor macros, needed at both compile and run times. . ,(DO ((VS (DO ((OPTS OPTIONS (CDR OPTS))) ((NULL OPTS) NIL) (WHEN (EQ (CAAR-SAFE OPTS) :OUTSIDE-ACCESSIBLE-INSTANCE-VARIABLES) (RETURN (CDAR OPTS))) (WHEN (EQ (CAR OPTS) :OUTSIDE-ACCESSIBLE-INSTANCE-VARIABLES) (RETURN (MAPCAR #'(LAMBDA (X) (IF (ATOM X) X (CAR X))) INSTANCE-VARIABLES)))) (CDR VS)) (PREFIX (OR (CADR (ASSQ-CAREFUL :ACCESSOR-PREFIX OPTIONS)) (STRING-APPEND NAME "-"))) (ORDS (DO ((OPTS OPTIONS (CDR OPTS))) ((NULL OPTS) NIL) (WHEN (EQ (CAAR-SAFE OPTS) :ORDERED-INSTANCE-VARIABLES) (RETURN (CDAR OPTS))) (WHEN (EQ (CAR OPTS) :ORDERED-INSTANCE-VARIABLES) (RETURN (MAPCAR #'(LAMBDA (X) (IF (ATOM X) X (CAR X))) INSTANCE-VARIABLES))))) (RES NIL (CONS `(DEFSUBST-WITH-PARENT ,(INTERN1 (STRING-APPEND PREFIX (CAR VS))) ,NAME (,NAME) ,(IF (MEMQ (CAR VS) ORDS) `(%INSTANCE-REF ,NAME ,(1+ (FIND-POSITION-IN-LIST (CAR VS) ORDS))) `(SYMEVAL-IN-INSTANCE ,NAME ',(CAR VS)))) RES))) ((NULL VS) RES))) ,@(MAKE-RUN-TIME-ALTERNATIVE-DEFFLAVORS NAME (OR (CDR (ASSQ-CAREFUL ':RUN-TIME-ALTERNATIVES OPTIONS)) (CDR (ASSQ-CAREFUL ':MIXTURE OPTIONS)))) ',NAME))) ))