Article View: comp.lang.clos
Article #295Supplied-p in lambda-list (was Re: clos initforms'
From: Len Charest
Date: Thu, 12 Nov 1992 01:10
Date: Thu, 12 Nov 1992 01:10
30 lines
1738 bytes
1738 bytes
In article <BxHA1I.G6D@world.std.com>, jbk@world.std.com (Jeffrey B Kane) writes:
|> ... 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))
|>
|> 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?
The lambda list of the function supports this kind of test. See page 76 of CLtL2.
(defun make-test-class (&key (slot-1 3) (slot-2 nil existp))
(unless existp
(setq slot-2 slot-1))
(make-instance 'test-class :slot-1 slot-1 :slot-2 slot-2))
..................................................
Len Charest, Jr.
JPL Artificial Intelligence Group
charest@aig.jpl.nasa.gov
Technical Details
Message-ID:
<1992Nov12.011033.1990@jpl-devvax.jpl.nasa.gov>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!elroy.jpl.nasa.gov!ufo!Aig.Jpl.Nasa.Gov!charestReferences:
<BxHA1I.G6D@world.std.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!elroy.jpl.nasa.gov!ufo!Aig.Jpl.Nasa.Gov!charest From: charest@Aig.Jpl.Nasa.Gov (Len Charest) Subject: Supplied-p in lambda-list (was Re: clos initforms' Message-ID: <1992Nov12.011033.1990@jpl-devvax.jpl.nasa.gov> Sender: usenet@jpl-devvax.jpl.nasa.gov (For NNTP so rrn will be able to post) Nntp-Posting-Host: ai-cyclops Reply-To: charest@aig.jpl.nasa.gov Organization: NASA/Jet Propulsion Laboratory References: <BxHA1I.G6D@world.std.com> Date: Thu, 12 Nov 1992 01:10:33 GMT Lines: 30