home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / lisp / 3158 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.1 KB  |  37 lines

  1. Path: sparky!uunet!olivea!charnel!sifon!CC.UMontreal.CA!kardank
  2. From: kardank@ERE.UMontreal.CA (Kardan Kaveh)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Automatic evaluation of expression in CLOS slots
  5. Message-ID: <1993Jan3.023306.25733@cc.umontreal.ca>
  6. Date: 3 Jan 93 02:33:06 GMT
  7. Sender: news@cc.umontreal.ca (Administration de Cnews)
  8. Organization: Universite de Montreal
  9. Lines: 26
  10.  
  11. I would like to be able to place expressions in class slots, and have them
  12. transparently evaluated when accessed.  Is there a standard way of doing
  13. this?  Do I need the Meta Object Protocol for this?
  14.  
  15. For example, I would like behaviour similar to the following:
  16.  
  17. (defclass foo ()
  18.   ((slot-1 :accessor slot-1)))
  19.  
  20. (defvar x (make-instance 'foo))
  21.  
  22. (setf (slot-1 x) '(+ 2 2))
  23.  
  24. (slot-1 x)  -->  4
  25. (slot-value x 'slot-1)  -->  4
  26. (slot-expression x 'slot-1)  --> '(+ 2 2)
  27.  
  28. Thanks,
  29.  
  30. Kaveh
  31.  
  32. -- 
  33. ------------
  34. Kaveh Kardan                                       kaveh@taarna.UUCP
  35. Systeme Taarna                                     kardank@eole.umontreal.qc.ca
  36. Montreal Quebec Canada                             (514)844-8448
  37.