bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
To: Bruno Haible <bruno@clisp.org>
Cc: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>, bug-gnulib@gnu.org
Subject: Re: Node to first or last element of a sequential list in module list/xlist
Date: Sat, 3 Apr 2021 12:00:26 +0200	[thread overview]
Message-ID: <CAEYrNrTas0fUWjssF_sPnBuPscPeYZEJpqtfRa_ZfZ9u3admbg@mail.gmail.com> (raw)
In-Reply-To: <8298235.EpQcvWjFxo@omega>

[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]

Am Sa., 3. Apr. 2021 um 11:49 Uhr schrieb Bruno Haible <bruno@clisp.org>:

> Marc Nieper-Wißkirchen wrote:
> > > I don't understand. You want to use a list_node_t while adding nodes to
> > > the list? This is invalid, since the comments in gl_list.h say:
> > >
> > >   /* Type representing the position of an element in the list, in a way
> > > that
> > >      is more adapted to the list implementation than a plain index.
> > >      Note: It is invalidated by insertions and removals!  */
> > >   typedef struct gl_list_node_impl * gl_list_node_t;
> > >
> >
> > It won't work with removals but it does work with insertions because
> > gl_list_add_before/gl_list_add_after/... etc. all return new, valid list
> > node objects.
>
> While this may be true for the linked-list implementation, it is not true
> for the array-list and other implementation. But the point of the Gnulib
> list module is to allow the developer to switch to a different
> implementation
> without changing their algorithms. [1]
>

I understand the point about being able to switch to a different
implementation and subscribe to it, but I don't understand why there should
be a problem with array-list or other implementations. When I look into
"lib/gl_array_list.c", I see that a valid node is returned, namely the node
corresponding to the newly inserted element.  Besides, what's the point of
returning nodes if they weren't valid?  Note that we are not talking about
reusing the node object used as the argument to add_before or add_after.
That is invalid, indeed.

[-- Attachment #2: Type: text/html, Size: 2078 bytes --]

  reply	other threads:[~2021-04-03 10:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 15:52 Node to first or last element of a sequential list in module list/xlist Marc Nieper-Wißkirchen
2021-04-02 22:49 ` Bruno Haible
2021-04-03  7:03   ` Marc Nieper-Wißkirchen
2021-04-03  9:49     ` Bruno Haible
2021-04-03 10:00       ` Marc Nieper-Wißkirchen [this message]
2021-04-03 10:14         ` Bruno Haible
2021-04-03 10:26           ` Marc Nieper-Wißkirchen
2021-04-03 16:28             ` Bruno Haible
2021-04-03 16:46               ` Marc Nieper-Wißkirchen
2021-04-03 16:55                 ` Bruno Haible
     [not found]               ` <CAEYrNrTatLc1QcBPzhbs9b64Dv5P5J7HuR+Tj8o6QKh91u1jZw@mail.gmail.com>
2021-04-04 23:30                 ` Bruno Haible
2021-04-05 10:20                   ` Marc Nieper-Wißkirchen

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://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=CAEYrNrTas0fUWjssF_sPnBuPscPeYZEJpqtfRa_ZfZ9u3admbg@mail.gmail.com \
    --to=marc.nieper+gnu@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /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).