[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: init-method in PCL

  Return-Path: <burdorf@rand-unix.ARPA>
  Redistributed: CommonLoops.pa
  Received: from rand.org (RAND-UNIX.ARPA) by Xerox.COM ; 11 MAY 88 15:35:06 PDT
  Received: by rand.org; Wed, 11 May 88 15:17:34 PDT
  Message-Id: <8805112217.AA29660@rand.org>
  To: CommonLoops.pa@xerox.com
  Cc: burdorf@RAND-UNIX.ARPA
  Subject: init-method in PCL
  Date: Wed, 11 May 88 15:17:28 PDT
  From: burdorf@RAND-UNIX.ARPA
  Can anyone tell me how to do an "init-method" in PCL so that it works
  like init-method does in FLAVORS.  I tried fiddling with the 
  initialize-instance method but didn't get any good results.
  chris burdorf

We use something like this.  You can use either the PCL way of
specializing initialize-instance, or the old Flavors way of :INIT
:AFTER methods, or something like the new Flavors way using

(defclass vanilla () ())

(defmethod MAKE-INSTANCE ((class symbol) &rest init-options)
  (apply #'make-instance (symbol-class class) init-options))

(defmethod MAKE-INSTANCE ((class standard-class) &rest init-options)
  (let ((instance (apply #'pcl:mki class init-options)))
    (apply #'make-instance instance init-options)
    (:init instance init-options)

(defmethod MAKE-INSTANCE ((instance vanilla) &rest init-options)
  (declare (ignore init-options))

(defmethod  VANILLA :INIT (init-options)
  (declare (ignore init-options))