[Ecls-list] Trigger action when data structure is updated?
Rui Maciel
rui.maciel at gmail.com
Sun Oct 25 13:02:18 UTC 2009
Juan Jose Garcia-Ripoll wrote:
> Just to give you an idea, when you define a structure or a class, the
> Common Lisp environment creates a number of functions or methods to
> access the individual slots. In the case of structures this is rather
> strict in the way it is done.
>
> For CLOS objects one can change the class of the class that you are
> defining and thus customize the methods that are generated to access
> the class methods.
>
> I am doing some emphasis on this because CELLS may or may not be
> ported to ECL, but what you want to do can be implemented very easily,
> if not in a very efficient way -- to change the slot accessors while
> preserving some of the optimizations you may then need to do some more
> work.
Sounds good. I believe that, in my case, efficiency wouldn't be extremely
important as long as it would be possible to re-render the model without any
relevant latency. So that may not be a problem at all.
> #+ecl
> (setf clos:*optimize-slot-access* nil)
>
> (defclass my-metaclass (standard-class)
> ())
>
> (defmethod (setf clos:slot-value-using-class)
> (value (class my-metaclass) object slot)
> (format t "~&;;; Changing object ~A" object)
> (force-output)
> (call-next-method))
>
> (defclass foo ()
> ((a :initarg :a :accessor foo-a)
> b)
> (:metaclass my-metaclass))
>
> (defparameter a (make-instance 'foo :a 4))
>
> (print (foo-a *a*))
>
> (setf (foo-a *a*) 3)
>
> (print (foo-a *a*))
I tried to run your example on ecl and it appears it choked. The output is as
follows:
<ecl-output>
<snip/>
> (defparameter a (make-instance 'foo :a 4))
;;; Changing object #<a FOO>
A
> (print (foo-a *a*))
The variable *A* is unbound.
Available restarts:
1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.
Broken at SI:BYTECODES. [Evaluation of: (PRINT (FOO-A *A*))]
</ecl-output>
One other thing, when I try to run (RESTART-TOPLEVEL) this problem pops up:
<ecl-output>
>> (RESTART-TOPLEVEL)
Debugger received error: The function RESTART-TOPLEVEL is undefined.
Error flushed.
</ecl-output>
I've installed ecl from source, as the version available through the Ubuntu
repositories appeared to be a bit outdated (Version: 0.9j-20080306-5ubuntu1).
Could this set of problems be caused by a botched installation?
Rui Maciel
More information about the ecl-devel
mailing list