[cells-devel] A question about the use of vectors in CELLS

Kenneth Tilton kentilton at gmail.com
Sat May 16 20:30:31 UTC 2009



Peder Chr. Nørgaard wrote:
> Hello
> 
> I am attempting to use a vector as the value in a slot.  It does not
> work well in first attempt:
> 
> CL-USER> (use-package :cells)
> T
> CL-USER> (defparameter a1 (make-instance 'model :value (c-in #(1 2 3 4))))
> A1
> CL-USER> (defparameter a2 (make-instance 'model :value (c? (apply #'+ 
> (map 'list #'identity (value a1))))))
> A2
> CL-USER> (value a2)
> 10
> CL-USER> (setf (elt (value a1) 1) 5)
> 5
> CL-USER> (value a1)
> #(1 5 3 4)
> CL-USER> (value a2)
> 10
> 
> The VALUE slot of A2, depending on (VALUE A1) is not changing when (VALUE A1) 
> is, shall we call it "changed in place".
> 
> The cells version is 
> from  :pserver:anonymous:anonymous at common-lisp.net:/project/cells/cvsroot.
> 
> The Lisp system is SBCL is 1.0.18.0-2.
> 
> I would like to enquire whether I am simply doing something trivially wrong, 
> or whether this is something that simply cannot be done without a major CELLS 
> extension for support of vector values (like, FAMILY, can be viewed as a kind 
> of support for list values).  The latter answer may force me to reconsider an 
> implementation that I had in mind.

You are not doing anything wrong. As you guessed, you would need to 
extend Cells, but not all that much. Peter Hildebrandt did this for hash 
tables IIRC. Something about "store".

I suppose you are aware you could get by with Cells as it is if you 
could afford to do a copy-seq on the value each time so Cells could see 
something change.

kt






More information about the cells-devel mailing list