[elephant-devel] Persistent class slot

Warren Lynn wrn.lynn at gmail.com
Fri Jun 18 19:41:10 UTC 2010


>
>  You can do that without persistent class slots -- make a counter class and
> update its value.
> Something like this:
>
> (defpclass counter ()
>  ((classname :index t :initarg :classname)
>   (counter :initform 0)))
>
> Then you can increment it automatically:
>
> (defmethod initialize-instance ((foo bar) &key &allow-other-keys)
>  (let ((counter (get-instance-from-value 'counter 'classname 'bar)))
>    (incf (slot-value counter 'counter))))
>
> It isn't pretty but it will work.
> Moreover, you need to implement this only once, so it doesn't matter how it
> is implemented.
>
> If we implement class slots, they will work in a similar way under the
> hood.
>
>
>

Thanks. This is a neat trick.

BTW: for now I have dropped the use of Elephant for some reasons (my own
compilation issues with BDB, BDB licence, performance, query power). But
thank you and other Elephant developers very much for your help in my
investigation of this framework.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20100618/62745444/attachment.html>


More information about the elephant-devel mailing list