🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #285

clos initforms

#285
From: Eric Peterson x7644
Date: Mon, 09 Nov 1992 19:49
34 lines
1729 bytes
>>>>> On Mon, 9 Nov 1992 05:18:53 GMT, george@hsvaic.boeing.COM (George Williams) said:

   George> On Nov 9,  3:49pm, Eric Peterson x7644 wrote:
>    Jeffrey> (defclass test-class ()
>    Jeffrey> 	((slot-1	:initarg :slot-1
>    Jeffrey> 		:initform 1
>    Jeffrey> 		:accessor slot-1)
>    Jeffrey> 	(slot-2	:initarg :slot-2
>    Jeffrey> 		:initform ?????      ; <- The question
>    Jeffrey> 		:accessor slot-2)))
> 
>    Jeffrey> The problem is that I need for slot-2 to default to the same value as
>    Jeffrey> slot-1 if the user does not specify it in the constructor.
> 
> I believe the following will do what you want provided that you are
> willing to call with :slot-2 first when both initargs are used (see
> CLtL2 28.1.9.4. first paragraph after the last bullet):
> 
> (defclass test-class ()
>   ((slot-1 :initarg :slot-1
>            :initform 1
>            :accessor slot-1)
>    (slot-2 :initarg :slot-1 :initarg :slot-2 
>            :accessor slot-2)))
> 
> 
> Required call order for non-defaulting case:
> 
> (make-instance 'test-clas :slot-2 5 :slot-1 3 )

   George> I don't mean to start a flame war, but I sure wouldn't want to maintain
   George> this kind of code.

   George> --george
Technical Details
Message-ID: <9211091949.AA21007@verdi.iisd.sra.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sra.COM!peterson
References: <9211091718.AA05876@hsvaic.boeing.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sra.COM!peterson
From: peterson@sra.COM (Eric Peterson x7644)
Subject: clos initforms
Message-ID: <9211091949.AA21007@verdi.iisd.sra.com>
Sender: daemon@cis.ohio-state.edu
Organization: The Ohio State University Department of Computer and Information Science
References: <9211091718.AA05876@hsvaic.boeing.com>
Date: Mon, 9 Nov 1992 19:49:20 GMT
Lines: 35