Re: intercepting (setf accessor)



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


.



Relevant Pages

  • Re: intercepting (setf accessor)
    ... What i want is a way to intercept calls to (setf (parent item-instance) parent-object) ... Find something somewhere on:before,:after,:around, and (call-next-method) and learn those. ...
    (comp.lang.lisp)
  • Re: Catch WM_SIZE
    ... I want to intercept this message IN my DIALOG. ... Not in my derived class. ... where it goes to initially, to the parent window, the dialog). ... parent who orders the child to resize in the first place. ...
    (microsoft.public.vc.mfc)
  • Re: Catch WM_SIZE
    ... I want to intercept this message IN my DIALOG. ... Not in my derived class. ... where it goes to initially, to the parent window, the dialog). ... parent who orders the child to resize in the first place. ...
    (microsoft.public.vc.mfc)
  • intercepting (setf accessor)
    ... What i want is a way to intercept calls to (setf (parent item-instance) ... That's why i don't really try intercepting (setf (slot-value item-instance ...
    (comp.lang.lisp)