Newsgroups: comp.lang.clos
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!swrinde!hookup!solaris.cc.vt.edu!uunet!in1.uu.net!franz.com!math.ufl.edu!kem
From: kem@math.ufl.edu (Kelly Murray)
Subject: CLOS instance initialization
Message-ID: <1995May29.013140.22148@franz.com>
Sender: news@franz.com
Nntp-Posting-Host: bell
Organization: University of Florida Department of Mathematics
Date: Mon, 29 May 1995 01:31:40 GMT
Lines: 36


> Does anyone know of a forum where folks are discussing CLOS?

Ok, let's talk about CLOS.

I'd like to get some discussion about how instances are initialized,
and whether people think it should be changed.

One difficulty with initialization of instances is that an application
can only really define :after methods on initialize-instance.

In many cases, it makes sense to run :before methods during initialization,
so that a subclass can do some stuff before its inherited superclasses
do their thing.  But you can't do this since only :after methods can
be defined, and hence run after the superclass methods run.

To get around this, an application will often define a standard
initialization method which is called in the :after initialize-instance
method, and all the initializations are really defined on this method.
A typical name might be "new-instance" or "initialize".

I was wondering how pervasive this is, and whether it might make
sense to standardize on this, and changing make-instance
to be defined to call another method after calling initialize-instance:

(defmethod make-instance ((class standard-class) &rest args)
   (let* ((initargs (default-initargs class args))
          (instance (allocate-instance class initargs))
     (apply #'initialize-instance instance initargs)
     (initialize instance)  ;; ADD THIS SO :BEFORE methods can run.
   ))

Anyone have an opinion or experience with how they do instance
initializations? 

-Kelly Murray    kem@franz.com    Franz Inc.  http://www.franz.com
