From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joe Corneli Newsgroups: gmane.emacs.help Subject: Re: sharing list structure Date: Thu, 24 Mar 2005 19:42:31 -0600 Message-ID: References: <1111712489.491757.194480@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1111715851 21086 80.91.229.2 (25 Mar 2005 01:57:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2005 01:57:31 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 25 02:57:31 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DEe43-00088U-Ez for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Mar 2005 02:56:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DEeJR-0003Ye-Sx for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Mar 2005 21:12:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DEeI7-0003L7-Tr for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 21:11:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DEeHz-0003GM-Tz for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 21:11:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DEeHz-0003E0-Kl for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 21:11:07 -0500 Original-Received: from [146.6.139.124] (helo=dell3.ma.utexas.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DEdqJ-0004GJ-Uo for help-gnu-emacs@gnu.org; Thu, 24 Mar 2005 20:42:32 -0500 Original-Received: from lab45.ma.utexas.edu (mail@lab45.ma.utexas.edu [128.83.133.159]) by dell3.ma.utexas.edu (8.11.0.Beta3/8.10.2) with ESMTP id j2P1gVC21878; Thu, 24 Mar 2005 19:42:31 -0600 Original-Received: from jcorneli by lab45.ma.utexas.edu with local (Exim 3.36 #1 (Debian)) id 1DEdqJ-0002ln-00; Thu, 24 Mar 2005 19:42:31 -0600 Original-To: help-gnu-emacs@gnu.org In-reply-to: <1111712489.491757.194480@g14g2000cwa.googlegroups.com> (rbielaws@i1.net) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org X-MailScanner-To: geh-help-gnu-emacs@m.gmane.org Xref: news.gmane.org gmane.emacs.help:25134 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25134 > 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. Well, I might be able to get by with using destructive functions to modify list A. It might be worth giving it a shot as an exercise... and if it works, so much the better. > 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) I think that you're right that this isn't quite like what I'm after. Let me describe the situation a bit better more... hopefully the details won't be overwhelming. I have two lists, H and F, and they both grow, shrink, and otherwise change. But, actually, I have several pairs of lists like this, H1, F1, H2, F2, etc., and at any given point in time, exactly one matched pair is to be assigned to H and F, H := Hk F := Fk However, I'm not just handed the H1 F1, ..., Hn Fn, rather, I wish to build up the collection from H's and F's over time. Thus, sometimes I also wish to run Hj := H Fj := F The data structure that I think ought to be capable of handling all of this would be a list B that contains ((title1, H1, F1), (title2, H2, F2), ..., (titlen, Hn, Fn)) This imposes an order on the of pairs Hk, Fk, and can be used at any give point in time to select the kth pair, or to do the assignment above, or just to manage all of this data. Of course, the list B can't have a fixed length in this set-up, since new Hk, Fk pairs may appear, or old ones deleted. To be honest, I can't think of a way to do what it seems you want in *any* language. Hopefully now that I've described the situation a bit more precisely it will be clear that it could be done with pointers: \| -> (V V V) T1 H1 F1 -> (V V V) T2 H2 F2 ........... The vertical dimension here is dynamic, and there is a 3rd dimension that is also dynamic, and it would be a pain to code it, I think, but it seems manageable. You'll have to forgive the quaint drawing style; I fear it mainly will illustrate my lack of C programming sense.