🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #287

Re: clos initforms'

#287
From: Jeffrey B Kane
Date: Tue, 10 Nov 1992 02:10
51 lines
1846 bytes
>Try using an :after method for initialize-instance on this class.

>E.g., (not tested),

>(defmethod initialize-instance :after ((new test-class) &key)
>  (unless (slot-boundp new 'slot-2)
>    (setf (slot-2 new) (slot-1 new))))

Dan,

This would work, however after looking at the various ways that I
should handle this, it looks like I should define a constructor
function, then check if various key words have been defined, i.e.

(defclass test-class ()
  ((slot-1	:initarg :slot-1
		:accessor slot-1)
   (slot-2	:initarg :slot-2
		:accessor slot-2)))

(defun make-test-class (&key (slot-1 3) slot-2)
  (unless (boundp slot2)
    (setf slot-2 slot-1))
  (make-instance 'test-class :slot-1 slot-1 :slot-2 slot-2))

The problem with this approach is that the function "boundp"
does not test if the user typed in a particular key word.

Calling:

(make-test-class :slot-2 4)

results in the error:

> Error: Unbound variable: SLOT2
> While executing: SYMBOL-VALUE

The reason I think that the constructor approach is bettter is than 
using initialize-instance :after is that it allows other key word and
a higher level of abstraction.  The the bottom line question is:

Other than defining a keyword with some kind of a value to flag it
hasn't been used, how can you test if it was used similar to slot-boundp
for slots?
     Jeffrey

================
Jeffrey Kane, MD
Kane Biomedical Systems

Internet jbk@world.std.com
Technical Details
Message-ID: <BxHA1I.G6D@world.std.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!sol.ctr.columbia.edu!eff!world!jbk

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!sol.ctr.columbia.edu!eff!world!jbk
From: jbk@world.std.com (Jeffrey B Kane)
Newsgroups: comp.lang.clos
Subject: Re: clos initforms'
Summary: boundp for keywords?
Message-ID: <BxHA1I.G6D@world.std.com>
Date: 10 Nov 92 02:10:29 GMT
Article-I.D.: world.BxHA1I.G6D
Organization: The World Public Access UNIX, Brookline, MA
Lines: 51