Article View: comp.lang.c
Article #2253Re: Iterators over slices and views and ranges analogs in C
From: Ross Finlayson
Date: Sat, 05 Dec 2026 16:44
Date: Sat, 05 Dec 2026 16:44
124 lines
6463 bytes
6463 bytes
On 12/04/2026 02:40 PM, Ross Finlayson wrote:
> On 12/04/2026 10:09 AM, bartc wrote:
>
> In C though now my current favorite idea is about this
> "lodge" list, basically saying that it's a memory layout.
>
>
> typedef struct {
> size_t lodge_size;
> size_t lodge_length;
>
> void* lodge_prev;
> void* lodge_next;
>
> void* lodge_head;
> void* lodge_tail;
>
> size_t member_size;
>
> off_t link_off;
> size_t link_count;
>
> off_t member_off;
> size_t member_count;
>
>
> } lodge_t;
>
> Then, that's looking that ten or eleven items in this struct,
> each 8-bytes so 88 bytes, for a node, then that the
> node, can fill the rest of the page with either links
> to items, _or_ items inline, calling items "members",
> then figuring that it's members-first then links, then
> that the functions to make iterators or access and maintenance
> work over those, is a usual sort of idea.
>
> Then the idea of this lodge-list is that a) it's like a linked-list,
> b) it's like an array, c) it tends to localize data in memory,
> d) it makes use of fixed-length resources each apiece for example
> a memory page, that a cache-line-pair of 128-many bytes is already
> mostly full by one of these, this kind of thing.
>
>
> Warm regards
>
>
This lodge-list then is an idea about what is a common sort of
data-structure, that's flexible, about that when all there is
is a bunch of memory pages of fixed size, yet the usual idiom
of list is a node element with an item value or pointer, about
how to make it a natural "layout", according to memory/storage
in C, so that it results a natural "structure", for example for
structured-programming, then later for abstraction & encapsulation
as "object-oriented programming", then sometimes designing about
the layout that's given by the system, is called "data-oriented
programming", though that's a bit the un-specific.
So, mixing qualities of "arrays" and "lists", and about the
aspects of the use-cases of arrays and lists as "containers"
or "collections", and about the maintenance and organization
and reorganization, has that data-structures involve more than
just access the accessors & mutators of the values, also
the accessor & mutator of the collection its membership, usually
insertion & deletion, and accessors & mutators of the collection its
organization in capacity & layout, usually growing and shrinking or
compaction & truncation.
It's sort of an idea, for example, "well if there's not a garbage
collector, might as well have a trash compactor".
char pages = char[10][4096];
So, the idea here is that to make a lodge-list, or "ldgl",
that pages[0] is the lodge and page[1] through page[9]
are members, then as about whether the "members" are
actually as of items as "char", that the vocabulary
is overloading itself and needs dis-ambiguation about
what otherwise are the direct natural terms relation suggests.
Then, there's a usual idea that a lodge would either
be pointing to large-ish blocks, themselves lodges or
treated as arrays, getting into types of members,
or, simply in-line as values themselves, about that
the "links" are to other lodges or arrays or lists,
and the "members" are the elements, for example members
of a collection. Thusly, when the members are small
compared to the lodge, link_count is 0 and member_count
ranges according to room remaining in the lodge, sort
of like "small-value optimization" in C++ they call it,
where an object type has enough room anyways to store
a small value, here point being to treat it as an array
of small values.
The idea here for making data structures that then
eventually support "iterators over slices and views
and ranges, in C", then is for various kinds of links,
for example to lodges or backing arrays, like memory
pages, then that lodges also have a previous & next,
so make a linked-list of those, then about insertion & deletion,
for example with just moving links or the semantics of nulls,
vis-a-vis soft-delete and these kinds of things, that
it's a sort of approach to layout then adapters then
that whatever memory allocation is given results a
generic collection of the type. Then also is for
that it's a serializable data structure, though
as pointers aren't serializable, a memo-izable
data structure (and related algorithms).
Technical Details
Message-ID:
<01ednd3cLZTuoon2nZ2dnZfqn_WdnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> <11esd12$mfam$1@raubtier-asyl.eternal-september.org> <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me> <11euadh$1gp4t$1@dont-email.me> <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org> <11eugtg$erg$4@dont-email.me> <11euj8b$1lhf1$1@dont-email.me> <i5-dnSCmSLz7R4_2nZ2dnZfqnPqdnZ2d@giganews.com> <11eupvu$1p0q1$1@dont-email.me> <0HydndKd_6bFbY_2nZ2dnZfqn_GdnZ2d@giganews.com> <11euu5h$1ra9d$1@dont-email.me> <ZYKdnah1_NuwnY72nZ2dnZfqnPidnZ2d@giganews.com> <11euvk1$1s4ed$1@dont-email.me> <0sScna9N05H83I72nZ2dnZfqnPadnZ2d@giganews.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 05 Dec 2026 16:44:35 +0000 Subject: Re: Iterators over slices and views and ranges analogs in C Newsgroups: comp.lang.c References: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> <11esd12$mfam$1@raubtier-asyl.eternal-september.org> <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me> <11euadh$1gp4t$1@dont-email.me> <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org> <11eugtg$erg$4@dont-email.me> <11euj8b$1lhf1$1@dont-email.me> <i5-dnSCmSLz7R4_2nZ2dnZfqnPqdnZ2d@giganews.com> <11eupvu$1p0q1$1@dont-email.me> <0HydndKd_6bFbY_2nZ2dnZfqn_GdnZ2d@giganews.com> <11euu5h$1ra9d$1@dont-email.me> <ZYKdnah1_NuwnY72nZ2dnZfqnPidnZ2d@giganews.com> <11euvk1$1s4ed$1@dont-email.me> <0sScna9N05H83I72nZ2dnZfqnPadnZ2d@giganews.com> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Sat, 5 Dec 2026 08:44:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <0sScna9N05H83I72nZ2dnZfqnPadnZ2d@giganews.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <01ednd3cLZTuoon2nZ2dnZfqn_WdnZ2d@giganews.com> Lines: 124 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-oIp9Zx2RYrpaAU/7ndtuyRjwqgQcGsGlQNNwur8ujhI/8ENW86StyiddsIZEDQh/FDF2ajp+DC1B+N8!ottMssJ/A4olRXA3paY0GxWQsu1ayb0xQQvXXDcoOGVhSRlHQAlEQ6V82lf7NhsYbOIUGn3lboIc!dA== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40