modifying the behavior of slot accessors

From: Brian Denheyer <>
Date: Thu, 25 Feb 1999 22:45:11 -0800 (PST)

Here is a class :

(define-class <foo> ()
 ((read-only :accessor read-only)
  (value :accessor value)))

Let's say that I want to control the way value is accessed based on
the value of read-only, so that if it is true and the program tries to
set a slot it won't work. It seems to me the proper way to do this is
to make value a virtual slot and modify the accessors :

(value :accessor value
       :allocation :virtual
         (lambda (self) (slot-ref self 'value)))

whoops ! the accessor is now infinitely recursive.

Obviously I can get around this by using define-method to create
read/writer methods, but it seems more elegant to do it the way I want
to. Is it possible ?

Brian Denheyer   
Deldot Design, Inc.        (503) 788-1607
\/.d = Electronic design and development
Received on Fri Feb 26 1999 - 07:45:52 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST