Good intuitive list patterns

monkyyy crazymonkyyy at gmail.com
Wed Feb 25 23:27:10 UTC 2026


On Saturday, 21 February 2026 at 09:25:20 UTC, monkyyy wrote:
> 

### rough intrusive list api:

there are three datatype familys: handles, elements, 
datastructures

Handles are a int-ish index + a mixin of a datastructure.

Elements are structs that need to contain a handle.

Datastructures are lists of elements, importantly []'s default 
operations must be worked around.

I see 2 problems to solve:
a) this is naively recursive so you must break the 
recursion(handles only get strings and may only contain lazy 
templates)
b) some data structures maybe naive that its part of an 
intrusive.. typethoery(?)

### naive vs knowledgable datastructures:

assume naive datastructures act like []'s:
   1. &[0] .. &[$-1] is owned by the datastructure and is entirely 
continuous
   2. ~= then [$-1] creates an element and gets you the element

knowledgeable datastuctures implement:
   1. add(element constructor arguments) returns a handle (~= is 
broken by slices)
   2. (enum) isvalidtype(T) returns if T can even exist in the 
datastructure
   3. getindex(ref T) returns a valid index for T, if you want 
safety do it here

elements implement:
   1. alias handle
   2. maybe uses the keywords: kid,sib,mom if you want my ranges

handles impliment:
   1. this(ref T)
   2. this(I)
   3. opAssign(ref T)
   4. opAssign(handle)

---

is that all expandable and the easiest thing to implement?


More information about the Digitalmars-d-learn mailing list