all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* sharing list structure
@ 2005-03-24 23:48 Joe Corneli
  2005-03-25  0:17 ` Denis Bueno
  0 siblings, 1 reply; 11+ messages in thread
From: Joe Corneli @ 2005-03-24 23:48 UTC (permalink / raw)



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.

If this was C, I think what I guess what I would say I want is a
"pointer to A".

But the elisp manual says --

   A note to C programmers: in Lisp, we do not distinguish between
   "holding" a value and "pointing to" the value, because pointers in
    Lisp are implicit.

So I guess what I want is an "implicit pointer" to A.


Looking at the box diagrams in the manual, it seemed to me that
everything would be taken care of if I used "setcdr" to build the list
B.  But that didn't quite work:

(progn
  (setq A '(1 2 3))
  (setq B (list 'foo))
  (setcdr B A)
  (setq A (append A (list 4)))
  B)
;=> (foo 1 2 3)

If I handle A with kid gloves, then B comes out right:

(progn
  (setq A '(1 2 3))
  (setq B (list 'foo))
  (setcdr B A)
  (setcdr (nthcdr 2 A) (list 4))
  B)
;=>(foo 1 2 3 4)

But is this the only way to go?  If it was possible, I would like to
set things up so that I could do anything I wanted to do to A, and
have B simply reflect that value at the end.

Is there a way to accomplish this?  And if it can't be done with
list structure alone, what other suggestions can you make?

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <mailman.173.1111709565.28103.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2005-03-26 23:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-24 23:48 sharing list structure Joe Corneli
2005-03-25  0:17 ` Denis Bueno
2005-03-25  0:27   ` Joe Corneli
2005-03-25  0:35     ` Denis Bueno
     [not found]   ` <mailman.176.1111711460.28103.help-gnu-emacs@gnu.org>
2005-03-25  1:21     ` Thien-Thi Nguyen
2005-03-26 23:58     ` Stefan Monnier
     [not found] <mailman.173.1111709565.28103.help-gnu-emacs@gnu.org>
2005-03-25  1:01 ` rgb
2005-03-25  1:42   ` Joe Corneli
     [not found]   ` <mailman.182.1111716692.28103.help-gnu-emacs@gnu.org>
2005-03-25  5:44     ` rgb
2005-03-25  5:49       ` rgb
2005-03-25  6:08       ` Joe Corneli

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.