unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Joe Corneli <jcorneli@math.utexas.edu>
Subject: Re: sharing list structure
Date: Thu, 24 Mar 2005 19:42:31 -0600	[thread overview]
Message-ID: <E1DEdqJ-0002ln-00@lab45.ma.utexas.edu> (raw)
In-Reply-To: <1111712489.491757.194480@g14g2000cwa.googlegroups.com> (rbielaws@i1.net)


   > 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.

  reply	other threads:[~2005-03-25  1:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.173.1111709565.28103.help-gnu-emacs@gnu.org>
2005-03-25  1:01 ` sharing list structure rgb
2005-03-25  1:42   ` Joe Corneli [this message]
     [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
2005-03-24 23:48 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1DEdqJ-0002ln-00@lab45.ma.utexas.edu \
    --to=jcorneli@math.utexas.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).