;;KLOS
;;AUTOLOAD: default-metaclass-instancier

;; the parent of the newly created class is expected as a 'father argument
;; to make-instance
;; warning: incomplete implementation: we should better treat the 
;; initialization of arguments

(defun default-metaclass-instancier (class call &aux
    newclass
    (i 1)
    (args (subseq call 1))
  )

  (setq newclass (eval
      `(defclass ,(gensym (class-name class))
	,(get args 'father Object)
	()
	:metaclass ,class
  )))
  (delete args 'father)
  (while (get args i ())
    (put newclass (getn args i) (getn args (+ 1 i)))
    (setq i (+ 1 2))
  )

  newclass
)

;;AUTOLOAD: default-metaclass-instancier-loader

(if (not (seek *error-correctors* 'default-metaclass-instancier-loader))
  (insert *error-correctors* 0 'default-metaclass-instancier-loader)
)

(defun default-metaclass-instancier-loader (errorcode &rest data)
  (if (= errorcode 'Errors:NoMetaclassInstanciation)
    (apply default-metaclass-instancier data)
    :nil
))
