Hi, it's me again, asking silly questions. This time I would like to know if there's a simple way to store a reference to a variable in another variable -- say, an element of vector or hash table.
I imagine this could look like this: (define v #(1 2 3)) (define v1 (vector-location v 1)) v1 : 2 (set! v1 10) v : #(1 10 3) I've tried to do it using a "procedure with setter", but the problem is that set! doesn't evaluate its first argument (as long as it's a symbol), so I'd have to wrap everything up in macros to obtain: (set! (vector-location v 1) 10) Besides I think that the names "hash-ref" and "vector-ref" are confusing, since they don't return references, but values (therefore the names like "vector-get" or "hash-get" would be more apropreate) I also wonder if there's any point for allowing locations to any sorts of variables (similar to pointers in C or pointers to C++), that is, (define x 10) (define y (location x)) (set! y 20) x : 20 I expect that this idea isn't new in the world of lisp, but I didn't find any discussion on the web. There are certainly some issues related with locations: - they require special behavior of set! and define: (set! y 20) could work in two different ways, depending on whether y is a location or not - what about "locations of locations"? - how would it affect performance? - what about multiple threads? Regards M.