home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / winlisp.zip / OOPL.LZH / OOPL.WL < prev    next >
Text File  |  1989-08-05  |  27KB  |  601 lines

  1. ;===============================================================================
  2. ; WINLISP:
  3. ;
  4. ;
  5. ;                    M I N I M U M    O. O. P.    L A Y E R
  6. ;
  7. ; Follows the ObjVLisp model (P. COINTE OOPSLA '87 proceedings) minus
  8. ; the multi-inheritance feature.
  9. ;
  10. ; AUTHOR:     Hussein SHAFIE
  11. ;
  12. ; COPYRIGHT:  Gregory POPOVITCH (c) 1989
  13. ;
  14. ; REQUIRES:   'cmonlib' and 'abbrev' packages
  15. ; CAVEATS:    - In this object model (unlike in the Smalltalk-80 model) class
  16. ;        variables are not inherited. That might cause some problems
  17. ;        if a class variable cv is referenced within a method of a 
  18. ;        class C:
  19. ;
  20. ;            [{MetaC} new 'name 'C
  21. ;                . . .
  22. ;                'cv        "cvstringvalue"
  23. ;                'methods    '(
  24. ;            aMess    (()
  25. ;                    . . .
  26. ;                    (if (equal #Ccv . . .
  27. ;                    . . .
  28. ;
  29. ;        and C has a subclass SubC whose class is not a kind of MetaC
  30. ;        (thus SubC instances have no acces to the cv class variable)
  31. ;        and that doesn't redefine a method for message aMess:
  32. ;
  33. ;            [{Class} new 'name 'SubC
  34. ;                 'superClass    {C}]
  35. ;
  36. ;        What do you think will happen at the execution time of:
  37. ;
  38. ;            [anInstanceOfSubC aMess]
  39. ;
  40. ;        Answer: a mess...
  41. ;
  42. ;          - For specification purposes, one may define an "empty" method 
  43. ;        for message aRequiredMess within the protocol of an abstract 
  44. ;        class AC.
  45. ;        This version of OOPL will not ensure that all non-abstract 
  46. ;        subclasses of AC actually implement a method for message 
  47. ;        aRequiredMess.
  48. ;          
  49. ;             - Redefining a method for message ooplInitialize in classes
  50. ;        other than Object and Class may be hazardous for the system.
  51. ;===============================================================================
  52.  
  53. (setq #:winlisp:colon 'oopl)
  54.  
  55. ;===============================================================================
  56. ;          if not already loaded, load abbreviations module;
  57. ;          and define some usefull functions.
  58. ;===============================================================================
  59. (unless (typefn 'get-abbrev) (loadfile "abbrev"))
  60.  
  61. (defun makelist (n s)
  62.        (if (<= n 0) () (cons s (makelist (1- n) s))))
  63. (setq :gensym-str "g" :gensym-idx 100)
  64. (defun gensym () (concat :gensym-str (incr :gensym-idx)))
  65. (synonym 'makevector 'make-vector)
  66.  
  67. ;===============================================================================
  68. ;                        E R R O R    M E S S A G E S
  69. ;===============================================================================
  70.  
  71. (defvar :notavar "not a symbol")
  72. (defvar :notalist "not a list")
  73. (defvar :badinstvarinit "usage: { <instance variable> <value> }*")
  74. (defvar :badmethdef "usage:  <name> '(' <args>  { <statements> }+  ')'")
  75. (defvar :notaninstvar "not an instance variable defined in class")
  76. (defvar :notaclassvar "not a class variable of class")
  77. (defvar :redefinstvar "instance variable redefined by subclass")
  78. (defvar :illinstvarref "reference of a class or instance variable outside a method")
  79. (defvar :doesnotunderstand "does not understand")        
  80. (defvar :sendqsyntax "usage: '[' <receiver>|super <selector> { <argument> }* ']'")        
  81. (defvar :illsendsuper "[super <selector> ... ] outside a method definition")
  82. (defvar :notaclass "not a class")
  83. (defvar :notinstantiable "abstract classes cannot be instantiated")
  84.  
  85. ;===============================================================================
  86. ;                      P R I V A T E    F U N C T I O N S
  87. ;===============================================================================
  88.  
  89. (defmacro :make-typed-vector (type length init)
  90.           ;; ------------------------------------------------------
  91.           ;; Return a vector typed <type> with <length> elements
  92.           ;; initialized to <init>.
  93.           ;; ------------------------------------------------------
  94.           `(let ( (new-vector (makevector ,length ,init)) )
  95.                 (typevector new-vector ,type)
  96.                 new-vector))
  97.  
  98. (defun :index (symbol list index)
  99.        ;; -------------------------------------------------------------
  100.        ;; Return the position index (starting at <index>) of <symbol> 
  101.        ;; in <list>.
  102.        ;; Return () if <symbol> is not a member of <list>.
  103.        ;; -------------------------------------------------------------
  104.        (when list
  105.              (if (eq symbol (car list))
  106.                  index
  107.                  ;;ELSE
  108.                  (:index symbol (cdr list) (1+ index)))))
  109.            
  110. (defun :initialize-instance (instance instvars inits)
  111.        ;; -------------------------------------------------------------
  112.        ;; Initialize some elements of vector <instance> according to
  113.        ;; the specification <inits>.
  114.        ;; <inits> is a list of associations symbolic key/value.
  115.        ;; <instvars> is a list of keys, the first key beeing a symbolic
  116.        ;; name for element 0 of the vector, the second for element 1, ...
  117.        ;; -------------------------------------------------------------
  118.        (when inits
  119.              (let* ( (instvar (car inits))
  120.                      (index   (:index instvar instvars 0)) )
  121.                    (unless index
  122.                            (error "{Class}:new"
  123.                                   :notaninstvar
  124.                                   (cons instvar 
  125.                                         (send 'name (send 'class instance)))))
  126.                    (unless (cdr inits)
  127.                            (error "{Class}:new" :badinstvarinit instvar))
  128.                    (vset instance index (cadr inits))
  129.                    (:initialize-instance instance instvars (cddr inits)))))
  130.  
  131. (defmacro :install-class (class-object class-name super-class-name)
  132.           ;; ------------------------------------------------------
  133.           ;; Define <class-name> as an abbreviation for the symbol:
  134.           ;; inheritance_path_up_to_<super-class-name>:<class-name>.
  135.           ;; Store <class-object> as the value of this "long" symbol.
  136.           ;; ------------------------------------------------------
  137.           `(let ( (class-symbol (if ,super-class-name
  138.                                     (symbol (get-abbrev ,super-class-name)
  139.                                             ,class-name)
  140.                                     ;;ELSE
  141.                                     ,class-name)) )
  142.                 (put-abbrev ,class-name class-symbol)
  143.                 (set class-symbol ,class-object)))
  144.  
  145. (defun :install-methods (class methods)
  146.        ;; -------------------------------------------------------------
  147.        ;; Install the methods <methods> defined at the class <class>
  148.        ;; creation time.
  149.        ;; -------------------------------------------------------------
  150.        (when methods
  151.              (send 'addMethod class (car methods) (cadr methods))
  152.              (:install-methods class (cddr methods))))
  153.                                  
  154. (defun :not-variablep (x)    (if (variablep x) () x))
  155.  
  156. (defun :merge-instvars (super-instvars self-instvars)
  157.        ;; -------------------------------------------------------------
  158.        ;; Check that <self-instvars> is a list of variables.
  159.        ;; Check that no element of <self-instvars> is also an element
  160.        ;; of <super-instvars>.
  161.        ;; -------------------------------------------------------------
  162.        (unless (listp self-instvars)
  163.                (error "{Class}:new" :notalist self-instvars))
  164.  
  165.        (let ( (bad-instvar (any ':not-variablep self-instvars)) )
  166.  
  167.             (when bad-instvar
  168.                   (error "{Class}:new" :notavar bad-instvar))
  169.  
  170.             (cond ( (null super-instvars)    self-instvars )
  171.                   ( (null self-instvars)    super-instvars )
  172.                   ( t                 ;CHECK FOR REDEFINED INSTANCE VARIABLES
  173.                     (setq bad-instvar
  174.                           (any '(lambda (instvar)
  175.                                         (when (member instvar super-instvars)
  176.                                               instvar))
  177.                                 self-instvars))
  178.                     (if bad-instvar
  179.                         (error "{Class}:new" :redefinstvar bad-instvar)
  180.                         ;;ELSE
  181.                         (nconc (copy super-instvars) self-instvars)) ))))
  182.                                         
  183. (defmacro :class (instance)        `(symeval (type-of ,instance)))
  184.  
  185. (defun :replace-refs (sexpr)
  186.        (when (consp sexpr)
  187.              (selectq (car sexpr)
  188.                       ( :instvar-ref
  189.                         (let* ( (instvar (cadr sexpr))
  190.                                 (index   (:index instvar *instvars* 0)) )
  191.                               (if index
  192.                                   (displace sexpr `(vref self ,index))
  193.                                   ;;ELSE
  194.                                   (error "{Class}:addMethod"
  195.                                          :notaninstvar 
  196.                                          (cons instvar *classname*)))) )
  197.                       ( :classvar-ref
  198.                         (let* ( (classvar (cadr sexpr))
  199.                                 (index    (:index classvar *classvars* 0)) )
  200.                               (if index
  201.                                   (displace sexpr 
  202.                                             `(vref (:class self) ,index))
  203.                                   ;;ELSE
  204.                                   (error "{Class}:addMethod"
  205.                                          :notaclassvar
  206.                                          (cons classvar *classname*)))) )
  207.                       ( :classname-ref
  208.                         (displace sexpr `(quote ,*classname*)) )
  209.                       ( t    
  210.                         (:replace-refs (car sexpr))
  211.                         (:replace-refs (cdr sexpr)) ))))
  212.        
  213. (defun :as-method (implementation instvars classvars classname)
  214.        ;; -------------------------------------------------------------
  215.        ;; Insert 'self' at the beginning of the lambda list starting
  216.        ;; <implementation>.
  217.        ;; Call :replace-refs in order to physically replace all instance
  218.        ;; variable references (if found in <instvars>), all class
  219.        ;; variable references (if found in <classvars>) by an equivalent
  220.        ;; call to vref and all class name references by the name of the
  221.        ;; class where the method is defined (<classname>).
  222.        ;; -------------------------------------------------------------
  223.        (let ( (*instvars*  instvars)
  224.               (*classvars* classvars)
  225.               (*classname* classname) )
  226.             (setf (car implementation) (cons 'self (car implementation)))
  227.             (:replace-refs (cdr implementation))
  228.             implementation))
  229.  
  230. ;;; ---------------------------------------------------------------------------
  231. ;;; Instance variable, class variable and class name references
  232. ;;; ---------------------------------------------------------------------------
  233.  
  234. (defmacro :instvar-ref (instvar)    `(error '|#I| :illinstvarref ,instvar))
  235.  
  236. (defsetf :instvar-ref (instvar) (val)    `(error '|#I| :illinstvarref ,instvar))
  237.  
  238. (defsharp |I| ()            `(:instvar-ref ,(read)))
  239.  
  240. (defmacro :classvar-ref (classvar)    `(error '|#C| :illinstvarref ,classvar))
  241.  
  242. (defsetf :classvar-ref (classvar) (val)    `(error '|#C| :illinstvarref ,classvar))
  243.  
  244. (defsharp |C| ()            `(:classvar-ref ,(read)))
  245.  
  246. (defmacro :classname-ref ()        `(error '|[| :illsendsuper ()))
  247.  
  248. ;;; ---------------------------------------------------------------------------
  249. ;;; The message passing syntax is:
  250. ;;;     '[' <receiver>|super <selector> { <argument> }* ']'
  251. ;;; The Lisp level syntax using send or send-super remains mandatory
  252. ;;; when the message selector has to be dynamically evaluated.
  253. ;;; ---------------------------------------------------------------------------
  254.  
  255. (dmc |]| ()        (error '|]| :sendqsyntax ()))
  256.  
  257. (dmc |[| ()
  258.      (let ( (receiver  (read)) 
  259.             (selector  (read)) )
  260.           (unless (variablep selector)
  261.                   (error '|[| :sendqsyntax selector))
  262.           (if (eq receiver 'super)
  263.               ;; |[| MUST CONS A NEW (:CLASSNAME-REF) EACH TIME IT IS CALLED
  264.               ;; BECAUSE THE PURPOSE OF THIS DUMMY FUNCTION IS TO BE PHYSICALLY 
  265.               ;; REPLACED BY AN ACTUAL CLASS NAME.
  266.               `(send-super ,(list ':classname-ref) ',selector self 
  267.                            ,.(read-delimited-list #/]))
  268.               ;;ELSE
  269.               `(send ',selector ,receiver ,.(read-delimited-list #/])))))
  270.  
  271. ;===============================================================================
  272. ;                       P U B L I C    F U N C T I O N S
  273. ;===============================================================================
  274.  
  275. ;(defun send (selector . receiver___args)
  276.        ;; -------------------------------------------------------------
  277.        ;; Send the message <selector> to the car of <receiver___args>
  278.        ;; with the cdr of <receiver___args> as arguments.
  279.        ;; -------------------------------------------------------------
  280. ;       (let ( (method (getfn (type-of (car receiver___args)) selector)) )
  281. ;            (if method
  282. ;                (apply method receiver___args)
  283. ;                ;;ELSE
  284. ;                (send 'doesNotUnderstand 
  285. ;                      (car receiver___args) 
  286. ;                      selector (cdr receiver___args)))))
  287.  
  288. (synonym 'send-super 'sendsuper)
  289. ;(defun send-super (classname selector . receiver___args)
  290.        ;; -------------------------------------------------------------
  291.        ;; Send the message <selector> to the car of <receiver___args>
  292.        ;; CONSIDERED AS BEING AN INSTANCE OF CLASS <classname>'s
  293.        ;; SUPERCLASS with the cdr of <receiver___args> as arguments.
  294.        ;; -------------------------------------------------------------
  295. ;       (let ( (method (getfn (packagecell classname) selector)) )
  296. ;            (if method
  297. ;                (apply method receiver___args)
  298. ;                ;;ELSE
  299. ;                (send-super classname 
  300. ;                            'doesNotUnderstand 
  301. ;                            (car receiver___args) 
  302. ;                            selector (cdr receiver___args)))))
  303.  
  304. ;;; ---------------------------------------------------------------------------
  305. ;;; "methods" inherited by both primitive objects and non primitive objects
  306. ;;; ---------------------------------------------------------------------------
  307. (defun class (self)        (:class self))
  308.  
  309. (defun isKindOf (self aClass)
  310.        [[self class] inheritsFrom aClass])
  311.         
  312. (defun doesNotUnderstand (self selector args)
  313.        (error 'doesNotUnderstand :doesnotunderstand (cons self selector)))
  314.  
  315.  
  316. ;===============================================================================
  317. ;                     F O U N D A T I O N    C L A S S E S
  318. ;===============================================================================
  319.  
  320. ;;; ---------------------------------------------------------------------------
  321. ;;; BOOTSTRAP PREPARATION: 
  322. ;;; In order to create the first classes 'Object' and then 'Class' the usual
  323. ;;; way (i.e. by sending the message 'new' to 'Class'), one has to do
  324. ;;; the hard way (by hand, in native lisp) first what will be automatically
  325. ;;; redone by the bootstrapped system.
  326. ;;; So the best documentation for the code that follows is its object oriented
  327. ;;; equivalent [{Class} new 'name 'Class 'superClass ...)
  328. ;;; ---------------------------------------------------------------------------
  329.  
  330. (put-abbrev 'Class '#:Object:Class)
  331.  
  332. (setq #:Object:Class
  333.       #:Object:Class:#[ Class
  334.                         ()
  335.                         (name superClass instanceVariables methods)
  336.                         () ])
  337.  
  338. (defun #:Object:Class:new (self . inits)
  339.        (let ( (name              (vref self 0))
  340.               (instanceVariables (vref self 2)) )
  341.             (send 'ooplInitialize
  342.                   (:make-typed-vector (get-abbrev name) 
  343.                                       (length instanceVariables) 
  344.                                       ())
  345.                   inits)))
  346.  
  347. (defun #:Object:Class:ooplInitialize (self inits)
  348.        (let ( (CinstanceVariables (vref (:class self) 2)) )
  349.             (:initialize-instance self CinstanceVariables inits))
  350.  
  351.        (let* ( (name               (vref self 0))
  352.                (superClass         (vref self 1))
  353.                (superClassName     (when superClass 
  354.                                          (send 'name superClass)))
  355.                (superClassInstvars (when superClass
  356.                                          (send 'instanceVariables superClass)))
  357.                (IinstanceVariables (vref self 2)) 
  358.                (methods            (vref self 3)) )
  359.              (:install-class self name superClassName)
  360.              (vset self 2 (:merge-instvars superClassInstvars 
  361.                                            IinstanceVariables))
  362.              (vset self 3 ())    
  363.              (:install-methods self methods)
  364.              self))
  365.  
  366. (defun #:Object:Class:addMethod (self selector implementation)
  367.        (let* ( (name               (get-abbrev (vref self 0)))
  368.                (functionName       (symbol name selector))
  369.                (IinstanceVariables (vref self 2))
  370.                (CinstanceVariables (vref (:class self) 2))
  371.                (methods            (vref self 3)) )
  372.              (apply 'defun (cons functionName
  373.                                  (:as-method implementation
  374.                                              IinstanceVariables
  375.                                              CinstanceVariables
  376.                                              name)))
  377.              (vset self 3 (nconc methods (list selector functionName)))))
  378.               
  379. (defun #:Object:Class:name (self)            (vref self 0))
  380.  
  381. (defun #:Object:Class:instanceVariables (self)        (vref self 2))
  382.  
  383. ;;; ---------------------------------------------------------------------------
  384. ;;; AbstractClass INSTANTIATION...
  385. ;;;    An abstract class will be used TO SPECIFY what is the structure/ 
  386. ;;;    behavior common to its subclasses and not directly as a template 
  387. ;;;    used to create objects. 
  388. ;;; ---------------------------------------------------------------------------
  389.  
  390. [{Class} new
  391.     'name        'AbstractClass
  392.         'superClass    {Class}
  393.         'methods    '(
  394.                                 
  395. new ( inits    
  396.     ;; -------------------------------------------------------------------    
  397.     ;; New is redefined to signal any attempt to instantiate an abstract
  398.     ;; class as an error.
  399.     ;; -------------------------------------------------------------------    
  400.           (error "{AbstractClass}:new" :notinstantiable self))
  401.  
  402. addMethod ((selector implementation)
  403.            ;; ------------------------------------------------------
  404.            ;; AddMethod is redefined in order to support an empty
  405.            ;; implementation for a method, this kind of definition
  406.            ;; being considered as a requirement spec for the receiver 
  407.            ;; subclasses.
  408.            ;; ------------------------------------------------------
  409.         (if (cdr implementation)
  410.                     [super addMethod selector implementation]
  411.                     ;;ELSE
  412.                     (setf #Imethods (nconc #Imethods (list selector ())))))
  413.  
  414. )]
  415.  
  416. ;;; ---------------------------------------------------------------------------
  417. ;;; Object INSTANTIATION...
  418. ;;; ---------------------------------------------------------------------------
  419.  
  420. [{AbstractClass}  new 
  421.        'name            'Object
  422.            'methods                    '(
  423.                                            
  424. ooplInitialize ((inits)
  425.            ;; ---------------------------------------------------
  426.            ;; Private - initialize the receiver as a terminal 
  427.            ;;           instance according to <inits>.
  428.            ;; ---------------------------------------------------
  429.                 (:initialize-instance self #CinstanceVariables inits)
  430.                 self)
  431.  
  432. )]
  433.  
  434. ;;; ---------------------------------------------------------------------------
  435. ;;; Class INSTANTIATION...
  436. ;;; Notice that the functions that implement new, ooplInitialize, addMethod...
  437. ;;; are overwritten during the Class instantiation WHILE THEY ARE EXECUTED!!!
  438. ;;; ---------------------------------------------------------------------------
  439. [{Class}  new
  440.            'name        'Class
  441.            'superClass        {Object}
  442.            'instanceVariables    '(name superClass instanceVariables methods)
  443.            'methods        '(
  444.  
  445. new ( inits
  446.     ;; -------------------------------------------------------------------    
  447.     ;; Non special objects basic constructor.
  448.     ;; Is able to create a new instance of the receiver initialized 
  449.     ;; according to <inits>.
  450.     ;; -------------------------------------------------------------------    
  451.       [(:make-typed-vector (get-abbrev #Iname) (length #IinstanceVariables) ())
  452.           ooplInitialize inits])
  453.  
  454. ooplInitialize ((inits)
  455.            ;; ----------------------------------------------------
  456.            ;; Private - initialize the receiver as a non terminal 
  457.            ;;           instance according to <inits>.
  458.            ;;           Implement static inheritance of instance
  459.            ;;           variables.
  460.            ;; ----------------------------------------------------
  461.                 [super ooplInitialize inits]
  462.                 (let* ( (superClass         #IsuperClass) 
  463.                         (superClassName     (when superClass 
  464.                                                   [superClass name]))
  465.                         (superClassInstvars (when superClass
  466.                                                   [superClass 
  467.                                                       instanceVariables]))
  468.                         (methods            #Imethods) )
  469.                       (:install-class self #Iname superClassName)
  470.                       (setf #IinstanceVariables 
  471.                             (:merge-instvars superClassInstvars
  472.                                              #IinstanceVariables))
  473.                       (setf #Imethods ())    
  474.                       (:install-methods self methods)
  475.                       self))
  476.              
  477. addMethod ((selector implementation)
  478.               (unless (and (variablep selector) (consp (cdr implementation)))
  479.                 (error "{Class}:addMethod" 
  480.                                :badmethdef (list selector implementation)))
  481.  
  482.                (let* ( (name         (get-abbrev #Iname))
  483.                         (functionName (symbol name selector)) )
  484.                       (apply 'defun (cons functionName
  485.                                           (:as-method implementation
  486.                                                       #IinstanceVariables
  487.                                                       #CinstanceVariables
  488.                                                       name)))
  489.                       (setf #Imethods (nconc #Imethods 
  490.                                              (list selector functionName)))))
  491.  
  492. name (()        #Iname)
  493.  
  494. superClass (()        #IsuperClass)
  495.  
  496. instanceVariables (()    #IinstanceVariables)
  497.  
  498. methods (()        #Imethods)
  499.  
  500. inheritsFrom ((aClass)
  501.           ;; -----------------------------------------------
  502.               ;; Answer t if the receiver inherits from aClass
  503.               ;; Implementation note:
  504.               ;;    without the test (equal aClass {Class})
  505.               ;;    this method loops forever due to the
  506.               ;;    reflexive nature of {Class}.
  507.           ;; -----------------------------------------------
  508.         (unless (or (equal aClass {Class}) [aClass isKindOf {Class}])
  509.                         (error "{Class}:inheritsFrom" :notaclass aClass))
  510.                 [self inheritsFromClass aClass])
  511.  
  512. inheritsFromClass ((aClass)
  513.             (or (eq #Iname [aClass name])
  514.                             (when #IsuperClass
  515.                                   [#IsuperClass inheritsFromClass aClass])))
  516.  
  517. showImplementationOf ((methodName)
  518.             (with ( (plist ':temp #Imethods) )
  519.                               (funcall 'print (valfn (getprop ':temp methodName)))))
  520.  
  521. ;prin (()        (prin "{" #Iname "}"))
  522.  
  523. )]
  524.  
  525. ;;; ---------------------------------------------------------------------------
  526. ;;; Attempt to integrate primitive objects...
  527. ;;; ---------------------------------------------------------------------------
  528.  
  529. [{Class} new
  530.       'name            'MetaPrimitiveObject
  531.           'superClass        {Class}
  532.           'instanceVariables    '(primitiveAllocator)
  533.           'methods        '(
  534.  
  535. new ( inits    (apply #IprimitiveAllocator inits))
  536.  
  537. primitiveAllocator ( userAllocator
  538.              ;; -----------------------------------------------
  539.                      ;; If <userAllocator> is provided, set primitive
  540.                      ;; allocator to that function, else answer the
  541.                      ;; value of the current primitive allocator.
  542.              ;; -----------------------------------------------
  543.                          (if userAllocator
  544.                 (setf #IprimitiveAllocator (car userAllocator))
  545.                             ;;ELSE
  546.                             #IprimitiveAllocator))
  547.  
  548. )]
  549.            
  550. [{MetaPrimitiveObject} new
  551.     'name               'symbol
  552.         'primitiveAllocator        '(lambda inits
  553.                                 (if inits
  554.                                                 (apply 'symbol inits)
  555.                                                 ;;ELSE
  556.                                                 (gensym)))]
  557.                                    
  558. [{MetaPrimitiveObject} new
  559.     'name               'string
  560.         'primitiveAllocator        '(lambda inits
  561.                                 (if inits
  562.                                                 (apply 'makestring inits)
  563.                                                 ;;ELSE
  564.                                                 (copy "")))]
  565.             
  566. [{MetaPrimitiveObject} new
  567.     'name               'vector
  568.         'primitiveAllocator        '(lambda inits
  569.                                 (if inits
  570.                                                 (apply 'makevector inits)
  571.                                                 ;;ELSE
  572.                                                 (makevector 0 ())))]
  573. [{MetaPrimitiveObject} new
  574.     'name               'cons
  575.         'primitiveAllocator        '(lambda inits
  576.                                 (if inits
  577.                                                 (apply 'makelist inits)
  578.                                                 ;;ELSE
  579.                                                 ()))]
  580.             
  581. [{MetaPrimitiveObject} new
  582.     'name               'float
  583.         'primitiveAllocator        '(lambda inits
  584.                                 (if inits
  585.                                                 (apply 'float inits)
  586.                                                 ;;ELSE
  587.                                                 0.))]
  588.             
  589. [{MetaPrimitiveObject} new
  590.     'name               'fix
  591.         'primitiveAllocator        '(lambda inits
  592.                                 (if inits
  593.                                                 (apply 'fix inits)
  594.                                                 ;;ELSE
  595.                                                 0))]
  596.             
  597. [{MetaPrimitiveObject} new
  598.     'name               'null
  599.         'primitiveAllocator        '(lambda inits ())]
  600.