Re: intercepting (setf accessor)
- From: Ivan Shvedunov <ivan_iv@xxxxxxxxxxxxxxxxx>
- Date: Sun, 19 Mar 2006 12:53:18 +0300
Maybe I'm wrong, but if you want to intercept slot changes in rather
general case it seems to me that while it's possible to avoid
MOP with some hacks, (SETF SLOT-VALUE-USING-CLASS)
http://www.lisp.org/mop/dictionary.html#(setf slot-value-using-class)
seems to be just what you need. Note though that e.g. in LW it is
implemented in not quite AMOP way (slot name is passed instead of
slot metaobject and default accessor implementations bypass this
method). This can be fixed by using Closer to MOP library:
http://common-lisp.net/project/closer/
Sacha wrote:
Still got more newbie questions..
This time it's more about architecture.
Let's say i have a class defined as follow :
(defclass item ()
((parent :accessor parent)))
What i want is a way to intercept calls to (setf (parent item-instance) parent-object)
in order to validate the new value, or maybe update an index or a database,
or whatever along those lines...
How would i go about doing this ?
I'd rather avoid MOP if possible.
That's why i don't really try intercepting (setf (slot-value item-instance 'parent) parent-object)
I thought about making eql specialisers on the fly, maybe using a
"closure builder" then releasing it when done with the item ...
but
1: i'm afraid this might be like using a cannon to kill a fly
2: i'm not quite sure how to do this
Also i don't really want to use a library that would do this
for me, as the real goal is learning.
Any ideas would be greatly apreciated.
Sacha
- Follow-Ups:
- Re: intercepting (setf accessor)
- From: Sacha
- Re: intercepting (setf accessor)
- References:
- intercepting (setf accessor)
- From: Sacha
- intercepting (setf accessor)
- Prev by Date: Re: Building a Windows CLISP
- Next by Date: Re: SBCL/lispbox setup non-threded
- Previous by thread: Re: intercepting (setf accessor)
- Next by thread: Re: intercepting (setf accessor)
- Index(es):
Relevant Pages
|