[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sharing list structure
From: |
rgb |
Subject: |
Re: sharing list structure |
Date: |
24 Mar 2005 17:01:29 -0800 |
User-agent: |
G2/0.2 |
Joe Corneli wrote:
> I'm not sure how to do the following:
>
> I have a list A, that grows, shrinks, and changes.
>
> I want to have a list B that includes list A within
> its list structure, along with other things, and that
> automatically keeps the "A" part of itself in synch
> with A.
>
There will certainly be some kid gloves involved because most of
the normal things you might want to do with A are destructive or
subversive to any pointer B might hold. The reason is, B is a
symbol in an obarray that points to a list element. That list
element might have a CDR which points to the same list element
that A points to but a change to A list can never cause the
pointer held by some element in list B to change. So any
operation involving setq A will very likely cause the
corresponding pointer in list B to point to an obsolete location.
> Is there a way to accomplish this? And if it can't be done with
> list structure alone, what other suggestions can you make?
I'm pretty sure this is not what you are looking for since
the position of the contents of B within list A is fixed.
(defmacro a+b () '`(,@A ,@B)) ;or any number of similar things
(setq A '(a b c d))
(setq B '(1 2 3 4))
(a+b)
=> (a b c d 1 2 3 4)
(setq a '(w x y z))
(setq b '(9 8 7 6))
(a+b)
=> (w x y z 9 8 7 6)
To be honest, I can't think of a way to do what it seems you
want in *any* language. But maybe I don't really understand.
- Re: sharing list structure,
rgb <=