🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.lisp.mcl
Article #601

Automatic evaluation of expressions in class slots

#601
From: Kardan Kaveh
Date: Sat, 02 Jan 1993 04:55
26 lines
1183 bytes
I would like to be able to place expressions in class slots, and have them
transparently evaluated when accessed.  Is there a standard way of doing
this?  Do I need the Meta Object Protocol for this?

For example, I would like behaviour similar to the following:

(defclass foo ()
  ((slot-1 :accessor slot-1)))

(defvar x (make-instance 'foo))

(setf (slot-1 x) '(+ 2 2))

(slot-1 x)  -->  4
(slot-value x 'slot-1)  -->  4
(slot-expression x 'slot-1)  --> '(+ 2 2)

Thanks,

Kaveh

-- 
------------
Kaveh Kardan                                       kaveh@taarna.UUCP
Systeme Taarna                                     kardank@eole.umontreal.qc.ca
Montreal Quebec Canada                             (514)844-8448
Technical Details
Message-ID: <1993Jan2.045508.12113@cc.umontreal.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!enterpoop.mit.edu!thunder.mcrcim.mcgill.edu!sifon!CC.UMontreal.CA!kardank

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.lisp.mcl
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!enterpoop.mit.edu!thunder.mcrcim.mcgill.edu!sifon!CC.UMontreal.CA!kardank
From: kardank@ERE.UMontreal.CA (Kardan Kaveh)
Subject: Automatic evaluation of expressions in class slots
Message-ID: <1993Jan2.045508.12113@cc.umontreal.ca>
Sender: news@cc.umontreal.ca (Administration de Cnews)
Organization: Universite de Montreal
Date: Sat, 2 Jan 1993 04:55:08 GMT
Lines: 26