🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #302

Re: class variables

#302
From: Barry Margolin
Date: Wed, 30 Sep 1992 19:58
38 lines
1455 bytes
In article <CUTTING.92Sep30102223@skye.parc.xerox.com> cutting@skye.parc.xerox.com (Doug Cutting) writes:
>As it stands, class allocation approximates DEFVAR.

Except that the user of the slot doesn't have to know whether it's a
per-instance or a per-class variable.

For instance, you can have a class slot that's overridden by an instance
slot in a subclass.  For instance:

(defclass elephant ()
  (color :reader elephant-color
	 :allocation :class
	 :initform 'grey))

(defclass painted-elephant (elephant)
  (color :allocation :instance
	 :initarg :color
	 :writer (setf elephant-color)))

or vice versa:

(defclass bear ()
  (color :accessor bear-color
	 :initarg :color))

(defclass polar-bear ()
  (color :allocation :class
	 :initform 'white))

(defmethod (setf bear-color) (color (self polar-bear))
  (unless (eq color 'white)
    (error ...)))

-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Technical Details
Message-ID: <1ad0tmINNbs0@early-bird.think.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
References: <HALTRAET.92Sep30032338@monsun.si.no> <CUTTING.92Sep30102223@skye.parc.xerox.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!sdd.hp.com!think.com!barmar
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.clos
Subject: Re: class variables
Date: 30 Sep 1992 19:58:46 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
Lines: 38
Message-ID: <1ad0tmINNbs0@early-bird.think.com>
References: <HALTRAET.92Sep30032338@monsun.si.no> <CUTTING.92Sep30102223@skye.parc.xerox.com>
NNTP-Posting-Host: telecaster.think.com