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

Question- initialize-in



        Reply to:   RE>Question:  initialize-insta
Cecil N. Huang asked:
> My question is this. How can I reverse what I did in step 2 so that the
> class I defined in 1 would go back to using the original, system default
> initialize-instance?

Just redefine initialize-instance so that it calls the next method
To see an example evaluate all s-expressions below one by one

(defclass test ()
  (
   (name :initarg :name :initform (gensym "TEST-OBJECT-") :accessor name
:documentation 
   "")
  )
  (:documentation
"")
  )

(describe (make-instance 'test))

;;; Forget the :after specializer
(defmethod initialize-instance ((obj test) &key)
  (format t "~%Created test-object ~a" (name obj)))

;;; Oh oh!!
(make-instance 'test)

;;; Fix
(defmethod initialize-instance ((obj test) &key)
  (call-next-method))
(defmethod initialize-instance :after ((obj test) &key)
  (format t "~%Created test-object ~a" (name obj)))

;;; Test
(make-instance 'test)

Hope this helps you out

Andre

--------------------------------------
Date: 5/18/93 2:46 PM
To: Andre Koehorst
From: Cecil Huang
Received: by riks.nl (2.01/GatorMail-Q); 18 May 93 14:46:17 U
Received: from sun4nl.UUCP by london with UUCP
          id AA27328; Tue, 18 May 93 14:46:01 +0200
Received: from brazil.cambridge.apple.com by sun4nl.nluug.nl with SMTP
	id AA09207 (5.65b/CWI-3.3); Tue, 18 May 1993 14:29:44 +0200
Received: from ministry.cambridge.apple.com by brazil.cambridge.apple.com with
SMTP (5.64/25-eef)
	id AA05667; Tue, 18 May 93 08:27:46 -0400
	for andre@riks.nl
Received: by cambridge.apple.com (5.64/25-eef)
	id AA19796; Tue, 18 May 93 08:27:42 -0400
Received: from brazil.cambridge.apple.com by cambridge.apple.com with SMTP
(5.64/25-eef)
	id AA19792; Tue, 18 May 93 08:27:37 -0400
Received: from news.cambridge.apple.com by brazil.cambridge.apple.com with SMTP
(5.64/25-eef)
	id AA05659; Tue, 18 May 93 08:27:28 -0400
	for info-mcl@ministry.cambridge.apple.com
Received: by news.cambridge.apple.com (5.64/A/UX-3.00)
	id AA00710; Tue, 18 May 93 08:26:43 EDT
To: info-mcl@ministry.cambridge.apple.com
Path:
news.cambridge.apple.com!news.media.mit.edu!enterpoop.mit.edu!linus!agate!howland.reston.ans.net!wupost!decwrl!decwrl!morrow.stanford.edu!ksl-mac-79.stanford.edu!user
From: cecil@camis.stanford.edu (Cecil Huang)
Newsgroups: comp.lang.lisp.mcl
Subject: Question:  initialize-instance
Followup-To: comp.lang.lisp.mcl
Date: 18 May 1993 06:13:27 GMT
Organization: Section on Medical Informatics at Stanford
Lines: 19
Distribution: world
Message-Id: <cecil-170593231454@ksl-mac-79.stanford.edu>
Nntp-Posting-Host: ksl-mac-79.stanford.edu

Hello all,

I have a problem which I only know how to solve by exiting and reentering
MCL 2.0.  This has to do with initialize-instance:

 1.  First, I defined a class with some :initforms.
 2.  Then, I defined an initialize-instance on that class.
 *.   What I really wanted to do was define an initialize-instance :after
     so that the system's initialize-instance would still process the
     :initforms and the :initargs properly.

My question is this. How can I reverse what I did in step 2 so that the
class I defined in 1 would go back to using the original, system default
initialize-instance?


Thanks for all of your help!
Cecil N. Huang
cecil@camis.stanford.edu